Hi Saurav,
Kindly view this sample source code.
w_ftclear-AGKOA = 'S'.
w_ftclear-xnops = 'X'.
w_ftclear-AGKON = clear_doc-hkont.
w_ftclear-AGBUK = 'AF'.
w_ftclear-SELFD = 'BELNR'.
w_ftclear-XNOPS = 'X'.
w_ftclear-SELVON = clear_doc-belnr.
w_ftclear-selbis = clear_doc-belnr.
append w_ftclear to it_ftclear.
CLEAR w_ftclear.
wa_ftpost-count = '001'.
wa_ftpost-stype = 'K'. " 'P'. "'K'. " .
wa_ftpost-fnam = 'BKPF-BLDAT'.
wa_ftpost-fval = clear_doc-bldat.
CONCATENATE wa_ftpost-fval+6(2) wa_ftpost-fval+4(2) wa_ftpost-fval(4) INTO wa_ftpost-fval.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'K'.
wa_ftpost-count = '001'.
wa_ftpost-fnam = 'BKPF-BUDAT'.
wa_ftpost-fval = clear_doc-bldat.
CONCATENATE wa_ftpost-fval+6(2) wa_ftpost-fval+4(2) wa_ftpost-fval(4) INTO wa_ftpost-fval.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'K'.
wa_ftpost-fnam = 'BKPF-BLART'.
wa_ftpost-fval = 'ZR'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'K'.
wa_ftpost-fnam = 'BKPF-BUKRS'.
wa_ftpost-fval = 'AF'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'K'.
wa_ftpost-fnam = 'BKPF-WAERS'.
wa_ftpost-fval = 'INR'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'K'.
wa_ftpost-fnam = 'BKPF-BKTXT'.
IF P_NTCL IS NOT INITIAL.
wa_ftpost-fval = 'Neft Clearing'.
ELSE.
wa_ftpost-fval = 'Cheque Clearing'.
ENDIF.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'P'.
wa_ftpost-fnam = 'RF05A-AUGTX'.
IF P_NTCL IS NOT INITIAL.
wa_ftpost-fval = 'Neft Clearing'.
ELSE.
wa_ftpost-fval = 'Cheque Clearing'.
ENDIF.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
IF p_ot IS NOT INITIAL OR P_NTCL IS NOT INITIAL.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '001'.
wa_ftpost-fnam = 'RF05A-NEWBS'.
wa_ftpost-fval = '40'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
ELSE.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '001'.
wa_ftpost-fnam = 'RF05A-NEWBS'.
wa_ftpost-fval = '50'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
ENDIF.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '001'.
wa_ftpost-fnam = 'RF05A-NEWKO'.
wa_ftpost-fval = clear_doc-hkont.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '002'.
wa_ftpost-fnam = 'BSEG-WRBTR'.
wa_ftpost-fval = LV_AMT. "clear_doc-wrbtr.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
IF p_ot IS NOT INITIAL OR P_NTCL IS NOT INITIAL.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '002'.
wa_ftpost-fnam = 'RF05A-NEWBS'.
wa_ftpost-fval = '50'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
ELSE.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '002'.
wa_ftpost-fnam = 'RF05A-NEWBS'.
wa_ftpost-fval = '40'.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
ENDIF.
wa_ftpost-stype = 'P'.
wa_ftpost-count = '002'.
wa_ftpost-fnam = 'RF05A-NEWKO'.
wa_ftpost-fval = post_doc-hkont.
APPEND wa_ftpost to it_ftpost.
CLEAR wa_ftpost.
CALL FUNCTION 'POSTING_INTERFACE_START'
EXPORTING
I_CLIENT = sy-mandt
I_FUNCTION = 'C' "LIKE RFIPI-FUNCT
* I_GROUP = SPACE
* I_HOLDDATE = SPACE
* I_KEEP = SPACE
I_MODE = 'N' "'N'
I_UPDATE = 'S'
I_USER = sy-uname.
* I_XBDCC = SPACE
CALL FUNCTION 'POSTING_INTERFACE_CLEARING'
EXPORTING
I_AUGLV = 'UMBUCHNG' " 'AUSGZAHL'
I_TCODE = 'FB05'
I_SGFUNCT = l_sgfunct
* I_NO_AUTH = ' '
IMPORTING
E_MSGID = sy-msgid
E_MSGNO = sy-msgno
E_MSGTY = sy-msgty
E_MSGV1 = sy-msgv1
E_MSGV2 = sy-msgv2
E_MSGV3 = sy-msgv3
E_MSGV4 = sy-msgv4
* E_SUBRC = sy-subrc
TABLES
T_BLNTAB = IT_BLNTAB
T_FTCLEAR = IT_FTCLEAR
T_FTPOST = IT_FTPOST
T_FTTAX = IT_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.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'POSTING_INTERFACE_END'
EXPORTING
I_BDCIMMED = 'X'
* I_BDCSTRTDT = 'NO_DATE'
* I_BDCSTRTTM = NO_TIME
EXCEPTIONS
SESSION_NOT_PROCESSABLE = 1
OTHERS = 2.
IF NOT IT_BLNTAB IS INITIAL.
* APPEND LINES OF it_temp to it_delete.
APPEND LINES OF IT_BLNTAB TO it_result.
PERFORM delete.
ENDIF.
Hope it helpful,
Regards,
Venkat