SAP Account Receivables Reconciliation:

  • This can be done via 3 Types as follows,

1. FIFO Basis

2. Billing Document Number Basis

3. On Account Entry

Business Requirement:

  •             Customer need to use MT942 and MT940 files in same day to post AR Entry and it should be Reconciled automatically.
  •              If MT940/MT942 File not Contains Billing document Number but it will contain Virtual Account Number.
  •              Virtual Account number is combination of some sequence number with customer code, which is created at bank end based customer list shared by customer.

Project Scope:

  • The Scope of the Project is to implement the following Interfaces between Customer ERP and Bank for automating their AR posting process.

Solution:

Report 1:

  • Using Intraday file of MT942 following entries can be posted using Custom Development Report as follows,
  • If MT942 file contains Virtual Account number than following entries as possible.
  • Using SAP Standard Process Transaction FF_5, we can’t able to post customer Entry, so we need to do custom development only.
1st Set of Entry:
Customer Credit
Incoming GL Debit
2nd Set of Entry:
Incoming GL Credit
Main GL Debit
  • As you know End Of Day file of MT940 contains same entries, which is there in MT942 and some new transactions entries might there in MT940 file as well, if transaction happened at last minute before banking cut off time.
  • As you know each transaction of collection will contain some Reference number/Transaction number/ UTR Number, so these information will be captured in “Document Header Text”, while posting 1st Set of entry and 2nd Set of entry as mention above.
  • We can create log table in R/3 environment where same set of entry or same file can’t be reprocessed using our report, so no duplication entry posted in R/3 Environment.
  • Using this MT940 File, whatever earlier entries posted via MT942 then those entries won’t be posted in R/3 environment and new MT940 file transaction entries will be posted in R/3 environment as mention above.

2nd Report:

  • We can create report, which is used to clear Incoming GL both Debit/ Credit entries based on Reference number/Transaction number/ UTR Number as well as amount using FB05 transaction.
  • This report can be scheduled via background job.
  • This Incoming GL Debit and Credit entry can be cleared based some assignment field using Standard Transaction F.13

TRANSACTION : F.13
CONFIGURATION T-CODE: OB74

HOW TO CONFIGURE OB74 TRANSACTION:
—————————

ACCTYPE : S
FROM ACCT: 34432
TO   ACCT: 34432
CRITERION 1: XBLNR (MEANS REFERENCE NUMBER BASED CLEAR ON ACCOUNT ENTRIES)

SAME WAY WE CAN USE CRITERION : GSBER OR DMBTR OR EBELN OR EBELP OR
ZUONR OR PRCTR ,ETC.,

Note:

  • This VA Posting can be done either MT942 alone or MT940 alone as well, so it’s not mandatory like we need to use both files as well.

Source Code of Report 1:

Include zcb_data_declarations.

Include zcb_selection_screen.

include zcb_main_program.

*&———————————————————————*
*&  Include           ZCB_DATA_DECLARATIONS
*&———————————————————————*

TYPE-POOLS: SLIS.

TABLES: ZCB_CUST_VANO, ” customer will maintain Customer code and corresponding VA number over here
ZSCB_VA_GL,
ZSCB_VA_LOG.

TYPES: BEGIN OF T_TEXT,
TEXT(4000),
END OF T_TEXT.

DATA: GIT_TEXT TYPE TABLE OF T_TEXT,
WA_TEXT TYPE T_TEXT.

TYPES: BEGIN OF TY_VA_ENTRY,
BUKRS TYPE BUKRS,
VA_NUMBER(40) TYPE C,
UTR_NO(24) TYPE C,
AMOUNT(22) TYPE C,
D_C_IND(2) TYPE C,
NARRATION TYPE SGTXT,
BAICODE(4) TYPE C,
VALUE_DATE TYPE DATS,
BANKN TYPE BANKN,
KUNNR TYPE KUNNR,
VA_IND TYPE C,
NVA_IND TYPE C,
GJAHR   TYPE GJAHR,
STM_NO(5) TYPE C,
END OF TY_VA_ENTRY.

DATA: GWA_VA TYPE TY_VA_ENTRY,
GIT_VA TYPE TABLE OF TY_VA_ENTRY.

DATA: P_FILE1 TYPE STRING,
GV_BUKRS TYPE BUKRS.

**—–DATA DECLARATION FOR F-02 POSTING
DATA: GWA_DOCHEADER TYPE BAPIACHE09,
GT_ACCGL TYPE TABLE OF  BAPIACGL09,
GWA_ACCGL TYPE BAPIACGL09,
GT_ACCREC TYPE TABLE OF BAPIACAR09,
GWA_ACCREC TYPE BAPIACAR09,
GT_RETURN TYPE TABLE OF BAPIRET2,
GWA_RETURN TYPE BAPIRET2,
GT_CURRAMT TYPE TABLE OF BAPIACCR09,
GWA_CURRAMT TYPE BAPIACCR09.

DATA: GIT_CUST TYPE TABLE OF ZSCB_CUST_VANO,
GWA_CUST TYPE ZSCB_CUST_VANO,
GV_FILENAME(1000) TYPE C,
GV_FILENAME1(1000) TYPE C.

DATA: IT_LOG TYPE TABLE OF ZSCB_VA_LOG,
WA_LOG TYPE ZSCB_VA_LOG,
GIT_GL TYPE STANDARD TABLE OF ZCB_VA_GL,
GWA_GL TYPE                   ZCB_VA_GL.

DATA: IT_FCAT TYPE  SLIS_T_FIELDCAT_ALV.

*&———————————————————————*
*&  Include           ZCB_MAIN_PROGRAM
*&———————————————————————*

START-OF-SELECTION.

**—-CB: Customer code and Virtual Account Number List

SELECT *
FROM ZCB_CUST_VANO
INTO TABLE GIT_CUST
WHERE BUKRS EQ P_BUKRS AND
KUNNR NE SPACE AND
VA_NO NE SPACE.
IF SY-SUBRC IS NOT INITIAL.
MESSAGE TEXT-035 TYPE ‘E’.
EXIT.
ENDIF.

**—-FETCH DATA FROM ZCB_VA_GL FOR DOC TYPE, G/L INFORMATION
SELECT *
FROM ZCB_VA_GL
INTO TABLE GIT_GL
WHERE BUKRS = P_BUKRS
AND   BLART <> SPACE
AND   IN_GL <> SPACE
AND   MAIN_GL <> SPACE.
IF SY-SUBRC IS NOT INITIAL.
MESSAGE TEXT-037 TYPE ‘E’.
EXIT.
ENDIF.

**—Get File Name

CALL FUNCTION ‘STRING_REVERSE’
EXPORTING
STRING    = P_FILE
LANG      = SY-LANGU
IMPORTING
RSTRING   = GV_FILENAME
EXCEPTIONS
TOO_SMALL = 1
OTHERS    = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

DATA: L_OFF TYPE I.

FIND ‘’ IN GV_FILENAME  MATCH OFFSET L_OFF.

CALL FUNCTION ‘STRING_SPLIT_AT_POSITION’
EXPORTING
STRING                  = GV_FILENAME
POS                     = L_OFF
*   LANGU                   = SY-LANGU
IMPORTING
STRING1                 =  GV_FILENAME
STRING2                 =  GV_FILENAME1
*   POS_NEW                 =
EXCEPTIONS
STRING1_TOO_SMALL       = 1
STRING2_TOO_SMALL       = 2
POS_NOT_VALID           = 3
OTHERS                  = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION ‘STRING_REVERSE’
EXPORTING
STRING    = GV_FILENAME
LANG      = SY-LANGU
IMPORTING
RSTRING   = GV_FILENAME
EXCEPTIONS
TOO_SMALL = 1
OTHERS    = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

**—UPLOAD MT940 FILE
P_FILE1 = P_FILE.

CALL FUNCTION ‘GUI_UPLOAD’
EXPORTING
FILENAME                = P_FILE1
FILETYPE                = ‘ASC’
TABLES
DATA_TAB                = GIT_TEXT[]    EXCEPTIONS
FILE_OPEN_ERROR         = 1
FILE_READ_ERROR         = 2
NO_BATCH                = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE            = 5
NO_AUTHORITY            = 6
UNKNOWN_ERROR           = 7
BAD_DATA_FORMAT         = 8
HEADER_NOT_ALLOWED      = 9
SEPARATOR_NOT_ALLOWED   = 10
HEADER_TOO_LONG         = 11
UNKNOWN_DP_ERROR        = 12
ACCESS_DENIED           = 13
DP_OUT_OF_MEMORY        = 14
DISK_FULL               = 15
DP_TIMEOUT              = 16
OTHERS                  = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

**—PARSING MT940 FILE TRANSACTION BY TRANSACTION
PERFORM PARSING_MT940_FILE_TRANS.
**—POSTING VA ENTRIES ALONE
PERFORM BDC_F_02_VA_POSTING_ENTRY.
**—POSTING NON VA ENTRIES
PERFORM BDC_F_02_NON_VA_POSTING_ENTRY.
**—DISPLAY LIST OF DETAILS
PERFORM DISPLAY_LIST.
*&———————————————————————*
*&      Form  BDC_F_02_VA_POSTING_ENTRY
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM BDC_F_02_VA_POSTING_ENTRY .

REFRESH: GT_ACCGL[],
GT_ACCREC[],
GT_CURRAMT[],
GT_RETURN[].

CLEAR: GWA_DOCHEADER.

LOOP AT GIT_VA INTO GWA_VA WHERE VA_IND EQ ‘X’.

READ TABLE GIT_GL INTO GWA_GL WITH KEY BUKRS = GWA_VA-BUKRS.

**—-F-02 TRANSACTION HEADER DETAILS INFORMATION

GWA_DOCHEADER-DOC_TYPE    = GWA_GL-BLART.
GWA_DOCHEADER-PSTNG_DATE =  GWA_VA-VALUE_DATE.”POSTING DATE AS TRANSACTION DATE
GWA_DOCHEADER-DOC_DATE = GWA_VA-VALUE_DATE.” DOCUMENT DATE AS TRANSACTION DATE
GWA_DOCHEADER-COMP_CODE   = GWA_VA-BUKRS.
GWA_DOCHEADER-FISC_YEAR = GWA_VA-GJAHR.” Current year

IF GWA_VA-UTR_NO IS NOT INITIAL.
GWA_DOCHEADER-HEADER_TXT  = GWA_VA-UTR_NO.
ENDIF.
GWA_DOCHEADER-USERNAME    = SY-UNAME.
GWA_DOCHEADER-BUS_ACT    = ‘RFBU’.

**—-FILL GL ENTRIES FOR F-02 TRANSACTION 1ST LINE ITEM
**—DEBIT GL
GWA_ACCGL-ITEMNO_ACC = ‘1’.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT  = GWA_GL-MAIN_GL
IMPORTING
OUTPUT = GWA_GL-MAIN_GL.
GWA_ACCGL-GL_ACCOUNT =  GWA_GL-MAIN_GL.
*          GWA_ACCGL-BUS_AREA = WA_F28-GSBER.
GWA_ACCGL-ALLOC_NMBR = GWA_VA-VALUE_DATE. “SY-DATUM. “DATE
IF GWA_VA-NARRATION IS NOT INITIAL.
GWA_ACCGL-ITEM_TEXT = GWA_VA-NARRATION.
ENDIF.
APPEND GWA_ACCGL TO GT_ACCGL.
CLEAR :GWA_ACCGL.

**—-FILL GL ENTRIES FOR F-02 TRANSACTION 2ND LINE ITEM
**—CREDIT GL
GWA_ACCGL-ITEMNO_ACC = ‘2’.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT  = GWA_GL-IN_GL
IMPORTING
OUTPUT = GWA_GL-IN_GL.
GWA_ACCGL-GL_ACCOUNT =   GWA_GL-IN_GL.
*          GWA_ACCGL-BUS_AREA = WA_F28-GSBER.
GWA_ACCGL-ALLOC_NMBR = GWA_VA-VALUE_DATE. “SY-DATUM. “DATE
IF GWA_VA-NARRATION IS NOT INITIAL.
GWA_ACCGL-ITEM_TEXT = GWA_VA-NARRATION.
ENDIF.
APPEND GWA_ACCGL TO GT_ACCGL.
CLEAR :GWA_ACCGL.

**—–FILL THE AMOUNT DETAILS FOR LINE ITEM
**—-DEBIT AMOUNT
GWA_CURRAMT-ITEMNO_ACC = ‘1’.
GWA_CURRAMT-CURRENCY = ‘INR’.
GWA_CURRAMT-AMT_DOCCUR = GWA_VA-AMOUNT.                 ” ’10’
APPEND GWA_CURRAMT TO GT_CURRAMT.
CLEAR: GWA_CURRAMT.
**—CREDIT AMOUNT
GWA_CURRAMT-ITEMNO_ACC = ‘2’.
GWA_CURRAMT-CURRENCY = ‘INR’.
GWA_CURRAMT-AMT_DOCCUR = GWA_VA-AMOUNT * -1.
APPEND GWA_CURRAMT TO GT_CURRAMT.
CLEAR: GWA_CURRAMT.

**—POST INCOMING CREDIT & MAINGL DEBIT ENTRY
PERFORM POST_F_02_BAPI.

**—DEBIT GL
GWA_ACCGL-ITEMNO_ACC = ‘1’.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT  = GWA_GL-IN_GL
IMPORTING
OUTPUT = GWA_GL-IN_GL.
GWA_ACCGL-GL_ACCOUNT=   GWA_GL-IN_GL.
*          GWA_ACCGL-BUS_AREA = WA_F28-GSBER.
GWA_ACCGL-ALLOC_NMBR = GWA_VA-VALUE_DATE. “SY-DATUM.
IF GWA_VA-NARRATION IS NOT INITIAL.
GWA_ACCGL-ITEM_TEXT = GWA_VA-NARRATION.
ENDIF.
APPEND GWA_ACCGL TO GT_ACCGL.
CLEAR :GWA_ACCGL.
**—CREDIT ENTRY FOR CUSTOMER CODE
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT  = GWA_VA-KUNNR
IMPORTING
OUTPUT = GWA_VA-KUNNR.

GWA_ACCREC-ITEMNO_ACC = ‘2’.
GWA_ACCREC-CUSTOMER = GWA_VA-KUNNR.
GWA_ACCREC-COMP_CODE = GWA_VA-BUKRS.
APPEND GWA_ACCREC TO GT_ACCREC.
CLEAR: GWA_ACCREC.

**—–FILL THE AMOUNT DETAILS FOR LINE ITEM
**—-DEBIT AMOUNT
GWA_CURRAMT-ITEMNO_ACC = ‘1’.
GWA_CURRAMT-CURRENCY = ‘INR’.
GWA_CURRAMT-AMT_DOCCUR = GWA_VA-AMOUNT.                 ” ’10’
APPEND GWA_CURRAMT TO GT_CURRAMT.
CLEAR: GWA_CURRAMT.
**—CREDIT AMOUNT
GWA_CURRAMT-ITEMNO_ACC = ‘2’.
GWA_CURRAMT-CURRENCY = ‘INR’.
GWA_CURRAMT-AMT_DOCCUR = GWA_VA-AMOUNT * -1.
APPEND GWA_CURRAMT TO GT_CURRAMT.
CLEAR: GWA_CURRAMT.

**—POST CUSTOMER CREDIT & INCOMING DEBIT ENTRY
PERFORM POST_F_02_BAPI.

CLEAR: GWA_DOCHEADER.

ENDLOOP.

ENDFORM.                    ” BDC_F_02_VA_POSTING_ENTRY
*&———————————————————————*
*&      Form  PARSING_MT940_FILE_TRANS
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM PARSING_MT940_FILE_TRANS .

DATA: DATE(2) TYPE C,
MONTH(2) TYPE C,
YEAR(4) TYPE C,
LV_DATE(10),
LV_MONTH TYPE WORKFLDS-MONTH,
LV_YEAR TYPE WORKFLDS-YEARN,
OFF TYPE I,
LAST_SART(4) TYPE C,
SATZ_61(2)    TYPE C VALUE ’61’,
SATZ_86(2)    TYPE C VALUE ’86’,
L_TABIX TYPE SY-TABIX,
L_POS TYPE I,
LV_BANKN TYPE BANKN,
LV_LEN TYPE I,
LV_N195 TYPE C,
LV_N169 TYPE C,
LV_STMNO(5) TYPE C.

DATA: SART(4) TYPE C,
ZEILE TYPE RAW_DATA_LINE.

LOOP AT GIT_TEXT INTO WA_TEXT.

TRANSLATE  WA_TEXT-TEXT TO UPPER CASE.
SART = WA_TEXT-TEXT+0(4).
ZEILE = WA_TEXT-TEXT.

IF SART+0(1) = ‘:’.
SHIFT ZEILE LEFT BY 4 PLACES.
ENDIF.
CASE SART(3).

WHEN ‘:25’.

REPLACE ALL OCCURRENCES OF ‘-‘ IN ZEILE WITH SPACE.
CONDENSE ZEILE NO-GAPS.

LV_BANKN = ZEILE.

**—FETCH COMPANY CODE BASED ON TAG: 25 ACCOUNT NUMBER

SELECT SINGLE BUKRS
FROM T012K
INTO GV_BUKRS
WHERE BUKRS EQ P_BUKRS AND
BANKN EQ LV_BANKN.

IF GV_BUKRS IS INITIAL.
MESSAGE TEXT-036 TYPE ‘E’.
EXIT.
ENDIF.

GWA_VA-BANKN = LV_BANKN.”Account number
GWA_VA-BUKRS = GV_BUKRS. “Company Code

WHEN ‘:28’.
IF SART+3(1) EQ ‘C’.
SHIFT ZEILE LEFT.
GWA_VA-STM_NO = ZEILE.
ENDIF.

**—-Validate MT940 File Statement Number for avoiding Duplicate Entries posting—–**

SELECT SINGLE STM_NO
FROM  ZSCB_VA_LOG
INTO LV_STMNO
WHERE STM_NO EQ GWA_VA-STM_NO.
IF SY-SUBRC IS INITIAL.
MESSAGE TEXT-038 TYPE ‘E’.
EXIT.
ENDIF.

WHEN ‘:61’.

FIND ‘CR’ IN ZEILE  MATCH OFFSET OFF.
IF SY-SUBRC IS INITIAL.

L_TABIX = SY-TABIX.
GWA_VA-D_C_IND = ‘CR’.

**—-VALUE DATE CALCULATION
DATE = ZEILE+4(2).
MONTH = ZEILE+2(2).
YEAR =  ZEILE+0(2).

LV_MONTH = YEAR .
**—-CONVERT TWO DIGIT YEAR INTO PROPER YEAR
CALL FUNCTION ‘CONVERT_YEAR_WITH_THRESHOLD’
EXPORTING
INPUT     = LV_MONTH
THRESHOLD = 50
IMPORTING
OUTPUT    = LV_YEAR.

GWA_VA-GJAHR = LV_YEAR.
CONCATENATE LV_YEAR MONTH DATE INTO LV_DATE.
CONDENSE LV_DATE NO-GAPS.
GWA_VA-VALUE_DATE = LV_DATE.

**——GET AMOUNT
DATA: LV_TEXT1(100),
LV_TEXT2(100).

FIND ‘N169’ IN ZEILE  MATCH OFFSET OFF.
IF SY-SUBRC IS INITIAL.
GWA_VA-BAICODE = ‘N169’.
SPLIT ZEILE AT ‘CR’ INTO LV_TEXT1 LV_TEXT2.
CLEAR: LV_TEXT1.
SPLIT LV_TEXT2 AT ‘N169’ INTO LV_TEXT1 LV_TEXT2.
IF SY-SUBRC IS INITIAL.
REPLACE ALL OCCURRENCES OF ‘,’ IN LV_TEXT1 WITH ‘.’.
GWA_VA-AMOUNT = LV_TEXT1.
CLEAR: LV_TEXT1.
ENDIF.                                          “N169

LV_N169 = ‘X’.

ELSE.

FIND ‘N195’ IN ZEILE  MATCH OFFSET OFF.
IF SY-SUBRC IS INITIAL.
GWA_VA-BAICODE = ‘N195’.
SPLIT ZEILE AT ‘CR’ INTO LV_TEXT1 LV_TEXT2.
CLEAR: LV_TEXT1.
SPLIT LV_TEXT2 AT ‘N195’ INTO LV_TEXT1 LV_TEXT2.
IF SY-SUBRC IS INITIAL.
REPLACE ALL OCCURRENCES OF ‘,’ IN LV_TEXT1 WITH ‘.’.
GWA_VA-AMOUNT = LV_TEXT1.
CLEAR: LV_TEXT1.
ENDIF.                                        “N195
LV_N195 = ‘X’.
ENDIF.                                          ” FIND N195
ENDIF.                                            “N169

LAST_SART = SATZ_61.

ENDIF. “CR

WHEN ‘:86’.
IF LAST_SART = SATZ_61.

CLEAR: LV_TEXT1,
LV_TEXT2.

L_TABIX = SY-TABIX.

IF LV_N195 = ‘X’.

**—-UTR NUMBER PICK FOR N195 TRANSACTION TAG 86 FIRST LINE ITSELF.

SPLIT ZEILE AT SPACE INTO LV_TEXT1 LV_TEXT2.
GWA_VA-UTR_NO = LV_TEXT2.

**——CAPTURE VA (Virtual Account Number)
L_POS = L_TABIX.
L_POS = L_POS + 2.
READ TABLE GIT_TEXT INTO WA_TEXT INDEX L_POS. “L_TABIX + 2.
IF SY-SUBRC IS INITIAL.
FIND ‘:61:’ IN WA_TEXT-TEXT  MATCH OFFSET OFF.
IF SY-SUBRC IS NOT INITIAL.
GWA_VA-VA_NUMBER = WA_TEXT-TEXT.
ENDIF.
ENDIF.
CLEAR: L_POS.
**—-Get Customer Code against Virtual Account Number

READ TABLE GIT_CUST INTO GWA_CUST WITH KEY BUKRS = P_BUKRS
VA_NO = GWA_VA-VA_NUMBER.
IF SY-SUBRC IS INITIAL.
GWA_VA-KUNNR = GWA_CUST-KUNNR.
GWA_VA-VA_IND = ‘X’.
ELSE.
GWA_VA-NVA_IND = ‘X’.
ENDIF.

**—-CAPTURE NARRATION
L_POS = L_TABIX.
L_POS = L_POS + 3.
READ TABLE GIT_TEXT INTO WA_TEXT INDEX L_POS. “L_TABIX + 3.
IF SY-SUBRC IS INITIAL.
FIND ‘:61:’ IN WA_TEXT-TEXT  MATCH OFFSET OFF.
IF SY-SUBRC IS NOT INITIAL.
GWA_VA-NARRATION = WA_TEXT-TEXT.
ENDIF.
ENDIF.
CLEAR: L_POS.

**—–SINGLE TRANSACTIONS DETAIL APPEND TO FINAL INTERNAL TABLE
APPEND GWA_VA TO GIT_VA.
CLEAR: LV_N195.
ENDIF.                                            “LV_N195

IF LV_N169 = ‘X’.
**—-UTR NUMBER PICK FOR N169 TRANSACTION TAG 86 1ST LINE
SPLIT ZEILE AT SPACE INTO LV_TEXT1 LV_TEXT2.
GWA_VA-UTR_NO = LV_TEXT2.
**——CAPTURE VA (Virtual Account Number)
L_POS = L_TABIX.
L_POS = L_POS + 2.
READ TABLE GIT_TEXT INTO WA_TEXT INDEX L_POS. “L_TABIX + 2.
IF SY-SUBRC IS INITIAL.
FIND ‘:61:’ IN WA_TEXT-TEXT  MATCH OFFSET OFF.
IF SY-SUBRC IS NOT INITIAL.
GWA_VA-VA_NUMBER = WA_TEXT-TEXT.
ENDIF.
ENDIF.
CLEAR: L_POS.
**—-Get Customer Code against Virtual Account Number

READ TABLE GIT_CUST INTO GWA_CUST WITH KEY BUKRS = P_BUKRS
VA_NO = GWA_VA-VA_NUMBER.
IF SY-SUBRC IS INITIAL.
GWA_VA-KUNNR = GWA_CUST-KUNNR.
GWA_VA-VA_IND = ‘X’.
ELSE.
GWA_VA-NVA_IND = ‘X’.
ENDIF.

**—-CAPTURE NARRATION
L_POS = L_TABIX.
L_POS = L_POS + 3.
READ TABLE GIT_TEXT INTO WA_TEXT INDEX L_POS. “L_TABIX + 3.
IF SY-SUBRC IS INITIAL.
FIND ‘:61:’ IN WA_TEXT-TEXT  MATCH OFFSET OFF.
IF SY-SUBRC IS NOT INITIAL.
GWA_VA-NARRATION = WA_TEXT-TEXT.
ENDIF.
ENDIF.
CLEAR: L_POS.
**—–SINGLE TRANSACTIONS DETAIL APPEND TO FINAL INTERNAL TABLE
APPEND GWA_VA TO GIT_VA.
CLEAR: LV_N169.

ENDIF.                                            “LV_N169

LAST_SART = SATZ_86.

ENDIF.

ENDCASE.

ENDLOOP.

ENDFORM.                    ” PARSING_MT940_FILE_TRANS
*&———————————————————————*
*&      Form  BDC_F_02_NON_VA_POSTING_ENTRY
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM BDC_F_02_NON_VA_POSTING_ENTRY .

REFRESH: GT_ACCGL[],
GT_ACCREC[],
GT_CURRAMT[],
GT_RETURN[].

CLEAR: GWA_DOCHEADER.

LOOP AT GIT_VA INTO GWA_VA WHERE NVA_IND EQ ‘X’.

READ TABLE GIT_GL INTO GWA_GL WITH KEY BUKRS = GWA_VA-BUKRS.
**—-F-02 TRANSACTION HEADER DETAILS INFORMATION

GWA_DOCHEADER-DOC_TYPE    = GWA_GL-BLART.
GWA_DOCHEADER-PSTNG_DATE =  GWA_VA-VALUE_DATE.”POSTING DATE AS TRANSACTION DATE
GWA_DOCHEADER-DOC_DATE = GWA_VA-VALUE_DATE.” DOCUMENT DATE AS TRANSACTION DATE
GWA_DOCHEADER-COMP_CODE   = GWA_VA-BUKRS.
GWA_DOCHEADER-FISC_YEAR = GWA_VA-GJAHR.

IF GWA_VA-UTR_NO IS NOT INITIAL.
GWA_DOCHEADER-HEADER_TXT  = GWA_VA-UTR_NO.
ENDIF.
GWA_DOCHEADER-USERNAME    = SY-UNAME.
GWA_DOCHEADER-BUS_ACT    = ‘RFBU’.

**—-FILL GL ENTRIES FOR F-02 TRANSACTION 1ST LINE ITEM
**—DEBIT GL
GWA_ACCGL-ITEMNO_ACC = ‘1’.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT  = GWA_GL-MAIN_GL
IMPORTING
OUTPUT = GWA_GL-MAIN_GL.
GWA_ACCGL-GL_ACCOUNT =  GWA_GL-MAIN_GL.
*          GWA_ACCGL-BUS_AREA = WA_F28-GSBER.
GWA_ACCGL-ALLOC_NMBR = GWA_VA-VALUE_DATE.
IF GWA_VA-NARRATION IS NOT INITIAL.
GWA_ACCGL-ITEM_TEXT = GWA_VA-NARRATION.
ENDIF.
APPEND GWA_ACCGL TO GT_ACCGL.
CLEAR :GWA_ACCGL.

**—-FILL GL ENTRIES FOR F-02 TRANSACTION 2ND LINE ITEM
**—CREDIT GL
GWA_ACCGL-ITEMNO_ACC = ‘2’.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT  = GWA_GL-IN_GL
IMPORTING
OUTPUT = GWA_GL-IN_GL.
GWA_ACCGL-GL_ACCOUNT = GWA_GL-IN_GL.
*          GWA_ACCGL-BUS_AREA = WA_F28-GSBER.
GWA_ACCGL-ALLOC_NMBR = GWA_VA-VALUE_DATE.
IF GWA_VA-NARRATION IS NOT INITIAL.
GWA_ACCGL-ITEM_TEXT = GWA_VA-NARRATION.
ENDIF.
APPEND GWA_ACCGL TO GT_ACCGL.
CLEAR :GWA_ACCGL.

**—–FILL THE AMOUNT DETAILS FOR LINE ITEM
**—-DEBIT AMOUNT
GWA_CURRAMT-ITEMNO_ACC = ‘1’.
GWA_CURRAMT-CURRENCY = ‘INR’.
GWA_CURRAMT-AMT_DOCCUR = GWA_VA-AMOUNT.                 ” ’10’
APPEND GWA_CURRAMT TO GT_CURRAMT.
CLEAR: GWA_CURRAMT.
**—CREDIT AMOUNT
GWA_CURRAMT-ITEMNO_ACC = ‘2’.
GWA_CURRAMT-CURRENCY = ‘INR’.
GWA_CURRAMT-AMT_DOCCUR = GWA_VA-AMOUNT * -1.
APPEND GWA_CURRAMT TO GT_CURRAMT.
CLEAR: GWA_CURRAMT.

**—POST INCOMING CREDIT & MAINGL DEBIT ENTRY
PERFORM POST_F_02_BAPI.

ENDLOOP.

ENDFORM.                    ” BDC_F_02_NON_VA_POSTING_ENTRY
*&———————————————————————*
*&      Form  POST_F_02_BAPI
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM POST_F_02_BAPI .

**——POST CREDIT LINE ITEM IN F-02 TRANSACTION VIA BAPI

CALL FUNCTION ‘BAPI_ACC_DOCUMENT_POST’
EXPORTING
DOCUMENTHEADER    = GWA_DOCHEADER
TABLES
ACCOUNTGL         = GT_ACCGL[]      ACCOUNTRECEIVABLE = GT_ACCREC[]      CURRENCYAMOUNT    = GT_CURRAMT[]      RETURN            = GT_RETURN[].

**—SAVE DATA IN DATABASE
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
WAIT = ‘X’.

**———————————————————————————————-*
**——writing log for sucesss records———————————————————*
**———————————————————————————————-*

READ TABLE GT_RETURN INTO GWA_RETURN WITH KEY TYPE = ‘S’
ID = ‘RW’
NUMBER = ‘605’.
IF SY-SUBRC IS INITIAL.

WA_LOG-KUNNR = GWA_VA-KUNNR.
WA_LOG-BUKRS = GWA_VA-BUKRS.
WA_LOG-BUDAT = GWA_VA-VALUE_DATE.               “SY-DATUM.
WA_LOG-AUGBL = GWA_RETURN-MESSAGE_V2+0(10).
WA_LOG-GJAHR = GWA_RETURN-MESSAGE_V2+14(4).”FISCAL YEAR
WA_LOG-DMBTR = GWA_VA-AMOUNT.
WA_LOG-BANKN = GWA_VA-BANKN.
WA_LOG-UZEIT = SY-UZEIT.
WA_LOG-UNAME = SY-UNAME.
WA_LOG-UTR_NO = GWA_VA-UTR_NO.
WA_LOG-COMMENTS = TEXT-056.                   “successfully Posted
WA_LOG-FILENAME = GV_FILENAME.
WA_LOG-BAICODE = GWA_VA-BAICODE.
WA_LOG-D_C_IND = GWA_VA-D_C_IND.
WA_LOG-STM_NO = GWA_VA-STM_NO.
WA_LOG-S_E_INDICATOR = ‘SUCCESS’.

APPEND WA_LOG TO IT_LOG.

INSERT ZSCB_VA_LOG FROM WA_LOG.
COMMIT WORK.
CLEAR WA_LOG.

ENDIF.

**———————————————————————————————-*
**——writing log for EXCEPTION records———————————————————*
**———————————————————————————————-*

READ TABLE GT_RETURN INTO GWA_RETURN WITH KEY TYPE = ‘E’
ID = ‘F5’.
IF SY-SUBRC IS INITIAL.

WA_LOG-KUNNR = GWA_VA-KUNNR.
WA_LOG-BUKRS = GWA_VA-BUKRS.
WA_LOG-BUDAT = GWA_VA-VALUE_DATE.               “SY-DATUM.
WA_LOG-AUGBL = ‘ ‘.
WA_LOG-GJAHR = GWA_VA-GJAHR.     “FISCAL YEAR
WA_LOG-DMBTR = GWA_VA-AMOUNT.
WA_LOG-BANKN = GWA_VA-BANKN.
WA_LOG-UZEIT = SY-UZEIT.
WA_LOG-UNAME = SY-UNAME.
WA_LOG-UTR_NO = GWA_VA-UTR_NO.
WA_LOG-COMMENTS = GWA_RETURN-MESSAGE.
WA_LOG-FILENAME = GV_FILENAME.
WA_LOG-BAICODE = GWA_VA-BAICODE.
WA_LOG-D_C_IND = GWA_VA-D_C_IND.
WA_LOG-STM_NO = GWA_VA-STM_NO.
WA_LOG-S_E_INDICATOR = ‘EXCEPTION’.
APPEND WA_LOG TO IT_LOG.

INSERT ZSCB_VA_LOG FROM WA_LOG.
COMMIT WORK.
CLEAR WA_LOG.

ENDIF.

REFRESH: GT_ACCGL[],
GT_ACCREC[],
GT_CURRAMT[],
GT_RETURN[].
ENDFORM.                    ” POST_F_02_BAPI
*&———————————————————————*
*&      Form  DISPLAY_LIST
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM DISPLAY_LIST .

**—-Get Field Catalog

CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
I_PROGRAM_NAME               = SY-CPROG
*   I_INTERNAL_TABNAME           = IT_LOG
I_STRUCTURE_NAME             = ‘ZSCB_VA_LOG’
*   I_CLIENT_NEVER_DISPLAY       = ‘X’
*   I_INCLNAME                   =
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
CHANGING
CT_FIELDCAT                  = IT_FCAT[]   EXCEPTIONS
INCONSISTENT_INTERFACE       = 1
PROGRAM_ERROR                = 2
OTHERS                       = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

**—Display ALV Grid

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
*   I_INTERFACE_CHECK                 = ‘ ‘
*   I_BYPASSING_BUFFER                = ‘ ‘
*   I_BUFFER_ACTIVE                   = ‘ ‘
I_CALLBACK_PROGRAM                =  SY-CPROG
*   I_CALLBACK_PF_STATUS_SET          = ‘ ‘
*   I_CALLBACK_USER_COMMAND           = ‘ ‘
*   I_CALLBACK_TOP_OF_PAGE            = ‘ ‘
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ‘ ‘
*   I_CALLBACK_HTML_END_OF_LIST       = ‘ ‘
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ‘ ‘
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
IT_FIELDCAT                       = IT_FCAT[]*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
I_DEFAULT                         = ‘X’
I_SAVE                            = ‘ ‘
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
TABLES
T_OUTTAB                          = IT_LOG
EXCEPTIONS
PROGRAM_ERROR                     = 1
OTHERS                            = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

REFRESH: IT_LOG[],
IT_FCAT[].

ENDFORM.                    ” DISPLAY_LIST

*&———————————————————————*
*&  Include           ZCB_SELECTION_SCREEN
*&———————————————————————*

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY,
P_BUKRS TYPE T001-BUKRS OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION ‘F4_FILENAME’
EXPORTING
PROGRAM_NAME  = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME    = ‘ ‘
IMPORTING
FILE_NAME     = P_FILE.

Source Code of Report 2:

*&———————————————————————*
*&  Include           ZFIE_DATA_DECLARATION_FB05
*&———————————————————————*

TABLES: BKPF,
BSIS.

**—–DATA DECLARATION

DATA: L_AUGLV   TYPE T041A-AUGLV   VALUE ‘UMBUCHNG’, “Posting with Clearing
L_TCODE   TYPE SY-TCODE      VALUE ‘FB05’,     “You get an error with any other value
L_SGFUNCT TYPE RFIPI-SGFUNCT VALUE ‘C’,        “Post immediately
T_TYPE      TYPE TRUXS_T_TEXT_DATA,
V_PARAM          TYPE VRM_ID,
V_VALUES         TYPE VRM_VALUES,
V_VALUE          LIKE LINE OF V_VALUES.

DATA: LT_BLNTAB  TYPE STANDARD TABLE OF BLNTAB  WITH HEADER LINE,
LT_FTCLEAR TYPE STANDARD TABLE OF FTCLEAR WITH HEADER LINE,
LT_FTPOST  TYPE STANDARD TABLE OF FTPOST  WITH HEADER LINE,
LT_FTTAX   TYPE STANDARD TABLE OF FTTAX   WITH HEADER LINE.

DATA: DATE(2) TYPE C,
MONTH(2) TYPE C,
YEAR(4) TYPE C,
LV_DATE(10).

DATA : GIT_MESSAGE TYPE TABLE OF BAPIRET2,
GWA_MESSAGE TYPE BAPIRET2,
L_SUBRC TYPE SY-SUBRC.

DATA: GC_HKONT(10) TYPE C.

TYPES: BEGIN OF TY_FB05,
BUZEI TYPE BSIS-BUZEI,
BUKRS TYPE BSIS-BUKRS,
BELNR TYPE BSIS-BELNR,
GJAHR TYPE BSIS-GJAHR,
HKONT TYPE BSIS-HKONT,
SHKZG TYPE BSIS-SHKZG,
DMBTR TYPE BSIS-DMBTR,
GSBER TYPE BSIS-GSBER,
BKTXT TYPE BKPF-BKTXT,
END OF TY_FB05.

DATA: GT_FB05 TYPE TABLE OF TY_FB05,
GWA_FB05 TYPE TY_FB05.

DATA: GT_BSIS TYPE TABLE OF BSIS,
GWA_BSIS TYPE BSIS,
GWA_BSIS1 TYPE BSIS,
GT_BKPF TYPE TABLE OF BKPF,
GWA_BKPF TYPE BKPF.

**—-SELECTION SCREEN INPUTS

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_BUKRS TYPE BSIS-BUKRS OBLIGATORY,
P_HKONT TYPE BSIS-HKONT OBLIGATORY.

SELECT-OPTIONS:
**S_BELNR FOR BSIS-BELNR,
S_BUDAT FOR BSIS-BUDAT OBLIGATORY.
**                S_GJAHR FOR BSIS-GJAHR OBLIGATORY.

PARAMETERS: P_CLDATE TYPE BSIS-BUDAT DEFAULT SY-DATUM OBLIGATORY.

*SELECT-OPTIONS: S_BLART FOR BSIS-BLART OBLIGATORY.

PARAMETERS :P_MODE TYPE C AS LISTBOX VISIBLE LENGTH 10 DEFAULT ‘N’.
SELECTION-SCREEN END OF BLOCK B1.

*———————————————————————*
*  At selection-screen Output
*———————————————————————*

AT SELECTION-SCREEN OUTPUT.

REFRESH :V_VALUES.

V_PARAM = TEXT-041.”‘P_MODE’.
V_VALUE-KEY = TEXT-042.”‘E’.
V_VALUE-TEXT = TEXT-043.” ‘Error’.
APPEND V_VALUE TO V_VALUES.
CLEAR V_VALUE.

V_PARAM = TEXT-044. “‘P_MODE’.
V_VALUE-KEY = TEXT-045. “‘A’.
V_VALUE-TEXT = TEXT-046. “‘All’.
APPEND V_VALUE TO V_VALUES.
CLEAR V_VALUE.

V_PARAM = TEXT-047. “‘P_MODE’.
V_VALUE-KEY = TEXT-048.”‘N’.
V_VALUE-TEXT = TEXT-049. “‘No’.
APPEND V_VALUE TO V_VALUES.
CLEAR V_VALUE.

CALL FUNCTION ‘VRM_SET_VALUES’
EXPORTING
ID              = V_PARAM
VALUES          = V_VALUES
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS          = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*&———————————————————————*
*&  Include           ZFIE_MAIN_POST_FB05
*&———————————————————————*

START-OF-SELECTION.

DATA: LV_COUNT TYPE I VALUE ‘1’,
LV_INDEX TYPE SY-TABIX.

**—-START BAPI AND POST DOCUMENT IN CALLTRANSACTION METHOD

CALL FUNCTION ‘POSTING_INTERFACE_START’
EXPORTING
I_FUNCTION         = ‘C’
I_MODE             = P_MODE “ALL SCREEN MODE
I_USER             = SY-UNAME
EXCEPTIONS
CLIENT_INCORRECT   = 1
FUNCTION_INVALID   = 2
GROUP_NAME_MISSING = 3
MODE_INVALID       = 4
UPDATE_INVALID     = 5
OTHERS             = 6.

IF SY-SUBRC IS NOT INITIAL.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

**—PEPSI FOODS FETCH OPEN ITEMS FOR AUTOMATIC CLEARING

SELECT  *
FROM BSIS
INTO TABLE  GT_BSIS
WHERE BUKRS EQ P_BUKRS AND
BUDAT IN S_BUDAT AND
HKONT EQ P_HKONT.” AND
**                BELNR IN S_BELNR AND
**                GJAHR IN S_GJAHR.

IF SY-SUBRC IS NOT INITIAL.

MESSAGE: ‘NO DOCUMENTS MATCH FOR INPUT DATA’ TYPE ‘E’.

ENDIF.

**—FETCHING HEADER DOCUMNET TEXT DETAILS FOR OPEN ITEMS

SELECT *
FROM BKPF
INTO TABLE GT_BKPF
FOR ALL ENTRIES IN GT_BSIS
WHERE BUKRS EQ GT_BSIS-BUKRS AND
BELNR EQ GT_BSIS-BELNR AND
GJAHR EQ GT_BSIS-GJAHR.

**—Adding Document Header Text in Final Structure

LOOP AT GT_BSIS INTO GWA_BSIS.

READ TABLE GT_BKPF INTO GWA_BKPF WITH KEY BUKRS = GWA_BSIS-BUKRS
BELNR = GWA_BSIS-BELNR
GJAHR = GWA_BSIS-GJAHR.
IF SY-SUBRC IS INITIAL.

GWA_FB05-BUKRS = GWA_BSIS-BUKRS.
GWA_FB05-BELNR = GWA_BSIS-BELNR.
GWA_FB05-GJAHR = GWA_BSIS-GJAHR.
GWA_FB05-HKONT = GWA_BSIS-HKONT.
GWA_FB05-SHKZG = GWA_BSIS-SHKZG.
GWA_FB05-DMBTR = GWA_BSIS-DMBTR.
GWA_FB05-GSBER = GWA_BSIS-GSBER.
GWA_FB05-BKTXT = GWA_BKPF-BKTXT.

APPEND GWA_FB05 TO GT_FB05.
CLEAR: GWA_FB05.

ENDIF.

ENDLOOP.

**—SORT INTERNAL DETAILS IN ASCENDING ORDER
SORT GT_FB05 BY BKTXT ASCENDING.

DATA: LV_HEADER_TEXT TYPE BKTXT,
LV_TABIX TYPE SY-TABIX,
LV_IND TYPE I VALUE ‘1’.

**—ASSIGN LINE ITEM DETAILS IN SEQUENCE ORDER
LOOP AT GT_FB05 INTO GWA_FB05.

LV_TABIX = SY-TABIX.

IF LV_TABIX = ‘1’.

LV_HEADER_TEXT = GWA_FB05-BKTXT.
GWA_FB05-BUZEI = LV_IND.
MODIFY GT_FB05 FROM GWA_FB05.

ELSE.”LV_TABIX

IF LV_HEADER_TEXT EQ GWA_FB05-BKTXT.

GWA_FB05-BUZEI = LV_IND.
MODIFY GT_FB05 FROM GWA_FB05.
ELSE.”LV_HEADER_TEXT
LV_IND = LV_IND + 1.

GWA_FB05-BUZEI = LV_IND.
MODIFY GT_FB05 FROM GWA_FB05.
LV_HEADER_TEXT = GWA_FB05-BKTXT.

ENDIF.”LV_HEADER_TEXT

ENDIF.  “LV_TABIX

ENDLOOP.

**——————————————————————-**
**—–CLEAR THE FOODS OPEN ITEMS————————————**
**——————————————————————-**

LOOP AT GT_FB05 INTO GWA_FB05.

DATA: L_SELVON TYPE SELXX_F05A,
L_SELBIS TYPE SELXX_F05A,
LV_BUKRS TYPE BSIS-BUKRS,
LV_BELNR TYPE BSIS-BELNR,
LV_GJAHR TYPE BSIS-GJAHR,
LV_HKONT TYPE BSIS-HKONT,
LV_BKTXT TYPE BKPF-BKTXT.

LV_BUKRS  = GWA_FB05-BUKRS.
LV_HKONT  = GWA_FB05-HKONT.

AT FIRST.

WRITE:/ ‘PEPSI FOODS CLEARED ENTRY INFORMATION DETAILS’ COLOR COL_POSITIVE INVERSE OFF.
ULINE.
WRITE:/ ‘COMPANY CODE : ‘ COLOR COL_NEGATIVE INVERSE ON, LV_BUKRS.
WRITE:/ ‘G/L INFO : ‘ COLOR COL_NEGATIVE INVERSE ON, LV_HKONT.
ULINE.

WRITE:/ ‘DOCUMENT.NO’ COLOR COL_NEGATIVE INVERSE ON,
14 ‘FISCAL YEAR’ COLOR COL_NEGATIVE INVERSE ON,
27 ‘UTR NO’ COLOR COL_NEGATIVE INVERSE ON,
51 ‘COMMENTS’ COLOR COL_NEGATIVE INVERSE ON.
ULINE.

ENDAT.

**—-CONCATENATE DOCUMENT NUMBER AND FISCAL YEAR

CONCATENATE  GWA_FB05-BELNR GWA_FB05-GJAHR INTO L_SELVON.
CONCATENATE  GWA_FB05-BELNR GWA_FB05-GJAHR INTO L_SELBIS.

**—-CLEARING DOCUMENT INFORMATION
LT_FTCLEAR-AGKOA = ‘S’. “‘D’.          “Account Type
LT_FTCLEAR-XNOPS = ‘X’.          “Indicator: Select only open items which are not special G/L?
LT_FTCLEAR-AGBUK = GWA_FB05-BUKRS. “COMPANY CODE
LT_FTCLEAR-AGKON = GWA_FB05-HKONT. “GL
LT_FTCLEAR-SELFD = ‘BELNR’.”Selection Field
LT_FTCLEAR-SELVON = L_SELVON. ” GWA_FB05-BELNR.
LT_FTCLEAR-SELBIS = L_SELBIS. “GWA_FB05-BELNR.
APPEND LT_FTCLEAR.

LV_BELNR  = GWA_FB05-BELNR.
LV_GJAHR  = GWA_FB05-GJAHR.
LV_BKTXT  = GWA_FB05-BKTXT.

AT END OF BUZEI.

**—-COLLECT DETAILS OF HEADER LINE
PERFORM FB05_HEADER_DETAILS.

****—CREATE NEW LINE ITEM FOR POSTING
**    PERFORM FB05_ITEM_DETAILS.

**—-POST DOCUMENT IN CALLTRANSACTION METHOD

CALL FUNCTION ‘POSTING_INTERFACE_CLEARING’
EXPORTING
I_AUGLV                    = L_AUGLV “Posting with Clearing
I_TCODE                    = L_TCODE “T-CODE FB05
I_SGFUNCT                  = L_SGFUNCT ” CALL TRANSACTION ‘C’
IMPORTING
E_MSGID                    = GWA_MESSAGE-ID
E_MSGNO                    = GWA_MESSAGE-NUMBER
E_MSGTY                    = GWA_MESSAGE-TYPE
E_MSGV1                    = GWA_MESSAGE-MESSAGE_V1
E_MSGV2                    = GWA_MESSAGE-MESSAGE_V2
E_MSGV3                    = GWA_MESSAGE-MESSAGE_V3
E_MSGV4                    = GWA_MESSAGE-MESSAGE_V4
E_SUBRC                    = L_SUBRC
TABLES
T_BLNTAB                   = LT_BLNTAB
T_FTCLEAR                  = LT_FTCLEAR
T_FTPOST                   = LT_FTPOST
T_FTTAX                    = LT_FTTAX
EXCEPTIONS
CLEARING_PROCEDURE_INVALID = 1
CLEARING_PROCEDURE_MISSING = 2
TABLE_T041A_EMPTY          = 3
TRANSACTION_CODE_INVALID   = 4
AMOUNT_FORMAT_ERROR        = 5
TOO_MANY_LINE_ITEMS        = 6
COMPANY_CODE_INVALID       = 7
SCREEN_NOT_FOUND           = 8
NO_AUTHORIZATION           = 9
OTHERS                     = 10.

**—–WRITE THE OUTPUT

DATA: V_MSG TYPE STRING.

CALL FUNCTION ‘FORMAT_MESSAGE’
EXPORTING
ID        = GWA_MESSAGE-ID
LANG      = ‘-D’
NO        = GWA_MESSAGE-NUMBER
V1        = GWA_MESSAGE-MESSAGE_V1
V2        = GWA_MESSAGE-MESSAGE_V2
V3        = GWA_MESSAGE-MESSAGE_V3
V4        = GWA_MESSAGE-MESSAGE_V4
IMPORTING
MSG       = V_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS    = 2.

WRITE:/  LV_BELNR,
14 LV_GJAHR,
27 LV_BKTXT,
51  V_MSG.

CLEAR: GWA_MESSAGE.

REFRESH: LT_FTPOST[],
LT_FTCLEAR[].

ENDAT.

ENDLOOP.

**—-END BAPI AND POST DOCUMENT IN CALLTRANSACTION METHOD

CALL FUNCTION ‘POSTING_INTERFACE_END’
EXPORTING
I_BDCIMMED              = ‘X’
EXCEPTIONS
SESSION_NOT_PROCESSABLE = 1
OTHERS                  = 2.
IF SY-SUBRC <> 0.
RETURN.
ENDIF.

*&———————————————————————*
*&      Form  FB05_HEADER_DETAILS
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM FB05_HEADER_DETAILS .

**—-BAPI INPUT VALUES OF HEADER

LT_FTPOST-STYPE = ‘K’.”Header
LT_FTPOST-COUNT = LV_COUNT. “1.  “number of Dynpro

CLEAR: YEAR,MONTH,DATE.
YEAR = SY-DATUM.
MONTH = SY-DATUM+4(2).
DATE = SY-DATUM+6(2).
CONCATENATE  DATE ‘.’ MONTH ‘.’ YEAR INTO LV_DATE.
CONDENSE LV_DATE NO-GAPS.

IF  P_CLDATE IS NOT INITIAL.

LT_FTPOST-FNAM = ‘BKPF-BLDAT’.
LT_FTPOST-FVAL = P_CLDATE.
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-BUDAT’.
LT_FTPOST-FVAL = P_CLDATE.
APPEND LT_FTPOST.

ELSE.

LT_FTPOST-FNAM = ‘BKPF-BLDAT’.
LT_FTPOST-FVAL = LV_DATE.
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-BUDAT’.
LT_FTPOST-FVAL = LV_DATE.
APPEND LT_FTPOST.

ENDIF.

LT_FTPOST-FNAM = ‘BKPF-BLDAT’.
LT_FTPOST-FVAL = LV_DATE.
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-BUDAT’.
LT_FTPOST-FVAL = LV_DATE.
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-BLART’.
LT_FTPOST-FVAL = ‘GI’. “‘DA’.   “DOCUMENT TYPE
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-BUKRS’.
LT_FTPOST-FVAL =  LV_BUKRS. ” “‘FLI’. “COMPANY CODE
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-WAERS’.
LT_FTPOST-FVAL = ‘INR’. ”       “CURRENCY
APPEND LT_FTPOST.

LT_FTPOST-FNAM = ‘BKPF-BKTXT’.”DOCUMENT HEADER TEXT
LT_FTPOST-FVAL = LV_BKTXT.
APPEND LT_FTPOST.

ENDFORM.                    ” FB05_HEADER_DETAILS

New NetWeaver Information at SAP.com

Very Helpfull

 

 

User Rating: Be the first one !