08-13-2015 11:09 AM
Hi friends,
I am currently designing an ALV grid in a module pool. I am transferring amount from the field AMOUNT to field AMOUNTSELECTED using checkbox. I need to create a new line item in FBL1N using the value present in AMOUNTSELECTED. The trick is that the field AMOUNT IN LOCAL CURRENCY in FBL1N will be having the amount present in field AMOUNTSELECTED. In my final table, IT_BSID_TEMP, the data is coming perfectly fine for both the line items. In FBL1N , a new document no will be generated for each line item. I am using BAPI_ACC_DOCUMENT_POST. I have given all the data required in IT_CURRENCYAMOUNT. I searched all the posts before in SDN regarding iconsistent currency. But i am unable to solve the issue. I checked in tcode OB22 also, the company code 1100 is present with curr type '10'. Please reply with corrections in the code and also provide tips on how to post for multiple line items in the internal table. Please go through the attachments .
Regards,
Saurav Lahiry
08-13-2015 12:00 PM
Hi
why you don't try with this FM BAPI_ACC_GL_POSTING_POST. may you can not get this error.
Just try it out,
Regards
Ibr
08-13-2015 12:00 PM
Hi
why you don't try with this FM BAPI_ACC_GL_POSTING_POST. may you can not get this error.
Just try it out,
Regards
Ibr
08-13-2015 12:03 PM
Hi,
just look to these FMs, and as I think they have the same tables what you want
CURRENCYAMOUNT
DOCUMENTHEADER
Regards
Ibr
08-20-2015 4:40 PM
Hi,
Sorry for the long delay in reply. But the problem is my requirement has been changed. I need to post tcodes F-44 and F-32 respectively. Is there a single BAPI or combination of BAPI's which can do the job? Or should i use BDC ? I want to use CALL TRANSACTION method since i have limited data . Please provide some sample code, if possible .
Regards,
Saurav Lahiry
08-13-2015 12:28 PM
You are appending it_accountgl with debit item(itemno_acc = 1) only. Append second line(itemno_acc = 2) for credit item.
CLEAR it_accountgl.
it_accountgl-itemno_acc = 2.
it_accountgl-gl_account = wa_bsid_temp-hkont.
it_accountgl-item_text = 'BAPI Test G/L line item'.
it_accountgl-customer = wa_bsid_temp-kunnr.
it_accountgl-de_cre_ind = wa_bsid_temp-shkzg.
it_accountgl-comp_code = so_bukrs-low.
it_accountgl-log_proc = ' '.
it_accountgl-doc_type = wa_bsid_temp-blart.
it_accountgl-pstng_date = sy-datum.
APPEND it_accountgl.
08-20-2015 4:41 PM
Hi Ujjaval,
Sorry for the long delay in reply. But the problem is my requirement has been changed. I need to post tcodes F-44 and F-32 respectively. Is there a single BAPI or combination of BAPI's which can do the job? Or should i use BDC ? I want to use CALL TRANSACTION method since i have limited data . Please provide some sample code, if possible .
Regards,
Saurav Lahiry
08-13-2015 1:32 PM
hi saurav,
Also it looks you are missing these values
it_currencyamount-currency_iso = 'INR'.
08-20-2015 4:40 PM
Hi Abdul,
Sorry for the long delay in reply. But the problem is my requirement has been changed. I need to post tcodes F-44 and F-32 respectively. Is there a single BAPI or combination of BAPI's which can do the job? Or should i use BDC ? I want to use CALL TRANSACTION method since i have limited data . Please provide some sample code, if possible .
Regards,
Saurav Lahiry
08-13-2015 2:07 PM
Only execute BAPI_TRANSACTION_COMMIT when there is no 'E'rror or 'A'bort message in RETURN parametert. So what is(are) the exact error message(s) raised ?
Hint: don't mismatch company currency whith document currency, also read 1444750 - Postings without transaction currency.
If success, remove those WAIT 10s statement, better try in a DO/ENDDO to read the generated document header (BKPF, with the obj* returned parameters mapped to AW* keys of index BKPF~4) and only wait 1s when not read. (And this only of you actually want to refresh the current line display)
Regards,
Raymond
08-13-2015 2:33 PM
Hi,
Try,
it_accountgl-itemno_acc = sy-tabix.
it_currencyamount-itemno_acc = sy-tabix.
IF it_accountgl-DE_CRE_IND = 'H'.
it_currencyamount = wa_bsid_temp-amountselected * - 1.
ELSE.
it_currencyamount = wa_bsid_temp-amountselected
ENDIF.
Pass the values to BAPI_ACC_DOCUMENT_CHECK then
BAPI_ACC_DOCUMENT_POST,'BAPI_TRANSACTION_COMMIT.
Hope it helpful,
Regards,
Venkat.
08-15-2015 4:22 PM
hi Venkat,
Thanks a lot for that tips. i solved that issue. Now, i have one new issue. If i click on 3 checkboxes in my alv grid, and i need to generate 3 different documents nos for those 3 rows in FB01 using BAPI_ACC_DOCUMENT_POST. How do i append the currency tables with line item nos 1 and 2 for the the three different records in IT_BSID_TEMP and pass it to BAPI_ACC_DOCUMENT_CHECK such that three different documents are created in FB01? I am getting an error 'Balance in transaction Currency' for multiple append currency tables even though i have given the same amount in debit and credit respectively with the proper sign. It works fine for a single record. Please reply with corrections in the code .
Regards,
Saurav Lahiry
DATA gd_documentheader LIKE bapiache09.
DATA l_type LIKE gd_documentheader-obj_type.
DATA l_key LIKE gd_documentheader-obj_key.
DATA l_sys LIKE gd_documentheader-obj_sys.
DATA it_accountgl LIKE TABLE OF bapiacgl09 WITH HEADER LINE.
DATA it_currencyamount LIKE TABLE OF bapiaccr09 WITH HEADER LINE.
DATA it_return LIKE TABLE OF bapiret2 WITH HEADER LINE.
DATA it_return1 LIKE TABLE OF bapiret2 WITH HEADER LINE.
DATA : extension1 like BAPIEXTC occurs 0 with header line.
* SORT it_bsid_temp BY buzei.
LOOP AT it_bsid_temp INTO wa_bsid_temp WHERE CHB EQ 'X'.
*AT NEW buzei.
*CONCATENATE '0' wa_bsid_temp-belnr '00' sy-datlo(4) INTO gd_documentheader-obj_key.
gd_documentheader-username = sy-uname.
gd_documentheader-header_txt = 'BAPI Test'.
gd_documentheader-comp_code = so_bukrs-low.
gd_documentheader-obj_type = 'BKPFF'.
gd_documentheader-obj_sys = sy-mandt.
gd_documentheader-obj_key = '$'.
*gd_documentheader-comp_code = so_bukrs-low.
gd_documentheader-fisc_year = wa_bsid_temp-gjahr.
gd_documentheader-doc_date = sy-datum.
gd_documentheader-pstng_date = sy-datum.
gd_documentheader-bus_act = 'RFBU'.
*gd_documentheader-fis_period = '05'.
gd_documentheader-doc_type = wa_bsid_temp-blart.
*LOOP AT it_bsid_temp INTO wa_bsid_temp.
CLEAR it_accountgl.
it_accountgl-itemno_acc = 1 .
it_accountgl-gl_account = wa_bsid_temp-hkont.
*it_accountgl-tax_code = 'V0'.
it_accountgl-item_text = 'BAPI Test G/L line item'.
it_accountgl-customer = wa_bsid_temp-kunnr.
*it_accountgl-profit_ctr = '0000002002'.
it_accountgl-de_cre_ind = wa_bsid_temp-shkzg.
it_accountgl-comp_code = so_bukrs-low.
*it_accountgl-log_proc = ' '.
it_accountgl-doc_type = wa_bsid_temp-blart.
*it_accountgl-fis_period = '06'.
*it_accountgl-fisc_year = '2009'.
it_accountgl-pstng_date = sy-datum.
APPEND it_accountgl.
CLEAR it_accountgl.
it_accountgl-itemno_acc = 2 .
it_accountgl-gl_account = wa_bsid_temp-hkont.
*it_accountgl-tax_code = 'V0'.
it_accountgl-item_text = 'BAPI Test G/L line item'.
it_accountgl-customer = wa_bsid_temp-kunnr.
*it_accountgl-profit_ctr = '0000002002'.
it_accountgl-de_cre_ind = wa_bsid_temp-shkzg.
it_accountgl-comp_code = so_bukrs-low.
*it_accountgl-log_proc = ' '.
it_accountgl-doc_type = wa_bsid_temp-blart.
*it_accountgl-fis_period = '06'.
*it_accountgl-fisc_year = '2009'.
it_accountgl-pstng_date = sy-datum.
APPEND it_accountgl.
CLEAR it_accountgl.
CLEAR it_currencyamount.
it_currencyamount-itemno_acc = 1.
it_currencyamount-curr_type = '00'.
it_currencyamount-currency = 'USD'.
it_currencyamount-currency_ISO = 'USD'.
it_currencyamount-amt_doccur = wa_bsid_temp-amountselected.
APPEND it_currencyamount.
CLEAR it_currencyamount.
it_currencyamount-itemno_acc = 2.
it_currencyamount-curr_type = '00'.
it_currencyamount-currency = 'USD'.
it_currencyamount-currency_ISO = 'USD'.
*IF wa_bsid_temp-shkzg EQ 'H'.
it_currencyamount-amt_doccur = wa_bsid_temp-amountselected * ( -1 ).
*ENDIF.
APPEND it_currencyamount.
CLEAR it_currencyamount.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
DOCUMENTHEADER = gd_DOCumentHEADER
TABLES
ACCOUNTGL = it_accountgl
* ACCOUNTRECEIVABLE = CUSTOMER
* ACCOUNTPAYABLE = VENDOR
CURRENCYAMOUNT = it_currencyamount
RETURN = it_RETURN1 .
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = gd_documentheader
IMPORTING
obj_type = l_type
obj_key = l_key
obj_sys = l_sys
TABLES
accountgl = it_accountgl
currencyamount = it_currencyamount
return = it_return.
*WAIT UP TO 10 SECONDS.
IF sy-subrc IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
LOOP AT it_return.
write : / it_return-type,
it_return-message,
it_return-number.
ENDLOOP.
08-15-2015 7:04 PM
Hi Saurav,
You need to generate new document numbers for individual selected records means you need to call the bapi fm inside the loop.
LOOP AT it_bsid_temp INTO wa_bsid_temp.
Clear:gd_documentheader.
Refresh:it_accountgl,it_currencyamount,it_return.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = gd_documentheader
IMPORTING
obj_type = l_type
obj_key = l_key
obj_sys = l_sys
TABLES
accountgl = it_accountgl
currencyamount = it_currencyamount
return = it_return.
ENDLOOP.
Hope it helpful,
Regards,
Venkat.
08-20-2015 4:39 PM
Hi Venkat,
Sorry for the long delay in reply. But the problem is my requirement has been changed. I need to post tcodes F-44 and F-32 respectively. Is there a single BAPI or combination of BAPI's which can do the job? Or should i use BDC ? I want to use CALL TRANSACTION method since i have limited data . Please provide some sample code, if possible .
Regards,
Saurav Lahiry
08-20-2015 5:06 PM
Hi Saurav,
For clearing use FM's
POSTING_INTERFACE_START
POSTING_INTERFACE_CLEARING.
POSTING_INTERFACE_END
Hope it helpful,
Regards,
Venkat
08-23-2015 11:50 AM
Hi Venkat,
Thanks a lot for that tips. I am currently facing a new issue now. I have an ALV grid which currently is fetching data from BSID table . I need to generate a new document using the value present in the field BALANCE . I used all the three FM's which were mentioned . But the BDC is not going to the other screens. Please make the necessary changes in the code.
Regards,
Saurav Lahiry
MODULE USER_COMMAND_8000 INPUT
WHEN 'POST'.
PERFORM clear_open_item.
ENDCASE.
ENDMODULE.
FORM CLEAR_OPEN_ITEM .
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
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.
LOOP AT it_bsid_temp INTO wa_bsid_temp.
CALL FUNCTION 'POSTING_INTERFACE_START'
EXPORTING
* I_CLIENT = SY-MANDT
i_function = 'C'
* I_GROUP = ' '
*
* I_HOLDDATE = ' '
*
* I_KEEP = ' '
I_MODE = 'A'
I_UPDATE = 'S'
I_USER = sy-uname
* I_XBDCC = ' '
EXCEPTIONS
CLIENT_INCORRECT = 1
FUNCTION_INVALID = 2
GROUP_NAME_MISSING = 3
MODE_INVALID = 4
UPDATE_INVALID = 5
OTHERS = 6.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Batch Input Values
lt_ftpost-stype = 'K'."Header
lt_ftpost-count = 1. "number of Dynpro
lt_ftpost-fnam = 'BSID-BLDAT'.
CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lt_ftpost-fval SEPARATED BY '.'.
APPEND lt_ftpost.
lt_ftpost-fnam = 'BSID-BUDAT'.
CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO lt_ftpost-fval SEPARATED BY '.'.
APPEND lt_ftpost.
lt_ftpost-fnam = 'BSID-BLART'.
lt_ftpost-fval = wa_bsid_temp-blart. "Same type as documents cleared via F-32
APPEND lt_ftpost.
*lt_ftpost-fnam = 'BKPF-WAERS'.
*
*lt_ftpost-fval = 'USD'. "Same type as documents cleared via F-32
*
*APPEND lt_ftpost.
lt_ftpost-stype = 'K'."Header
lt_ftpost-count = 1. "number of Dynpro
lt_ftpost-fnam = 'BSID-BUKRS'.
lt_ftpost-fval = wa_bsid_temp-bukrs.
APPEND lt_ftpost.
CLEAR lt_ftpost.
lt_ftpost-stype = 'K'."Header
lt_ftpost-count = 1. "number of Dynpro
lt_ftpost-fnam = 'BSID-BKTXT'.
lt_ftpost-fval = 'Intercompany clearing'.
APPEND lt_ftpost.
lt_ftpost-stype = 'K'."Header
lt_ftpost-count = 1. "number of Dynpro
lt_ftpost-fnam = 'BSID-WAERS'.
lt_ftpost-fval = wa_bsid_temp-waers.
APPEND lt_ftpost.
CLEAR lt_ftpost.
lt_ftpost-stype = 'P'."item
lt_ftpost-count = 1. "number of Dynpro
*lt_ftpost-fval = 'DR'.
*lt_ftpost-fnam = 'BSEG-WRBTR'.
lt_ftpost-fnam = 'BSEG-GJAHR'.
lt_ftpost-fval = wa_bsid_temp-gjahr. "Same type as documents cleared via F-32
APPEND lt_ftpost.
lt_ftpost-stype = 'P'."item
lt_ftpost-count = 1. "number of Dynpro
lt_ftpost-fnam = 'BSEG-BUZEI'.
lt_ftpost-fval = wa_bsid_temp-buzei. "Same type as documents cleared via F-32
APPEND lt_ftpost.
*lt_ftpost-stype = 'P'."item
*
*lt_ftpost-count = 1. "number of Dynpro
*lt_ftpost-fval = 'DR'.
*lt_ftpost-fnam = 'BSEG-WRBTR'.
lt_ftpost-stype = 'P'."item
lt_ftpost-count = 1. "number of Dynpro
lt_ftpost-fnam = 'BSEG-WRBTR'.
lt_ftpost-fval = wa_bsid_temp-balance. "Same type as documents cleared via F-32
APPEND lt_ftpost.
lt_ftpost-stype = 'P'."item
lt_ftpost-count = 2. "number of Dynpro
*lt_ftpost-fval = 'DR'.
*lt_ftpost-fnam = 'BSEG-WRBTR'.
lt_ftpost-fnam = 'BSEG-GJAHR'.
lt_ftpost-fval = wa_bsid_temp-gjahr. "Same type as documents cleared via F-32
APPEND lt_ftpost.
*lt_ftpost-stype = 'P'."item
*
*lt_ftpost-count = 1. "number of Dynpro
*lt_ftpost-fval = 'DR'.
*lt_ftpost-fnam = 'BSEG-WRBTR'.
lt_ftpost-stype = 'P'."item
lt_ftpost-count = 2. "number of Dynpro
lt_ftpost-fnam = 'BSEG-WRBTR'.
lt_ftpost-fval = wa_bsid_temp-balance * ( - 1 ). "Same type as documents cleared via F-32
APPEND lt_ftpost.
lt_ftpost-stype = 'P'."item
lt_ftpost-count = 2. "number of Dynpro
lt_ftpost-fnam = 'BSEG-BUZEI'.
lt_ftpost-fval = wa_bsid_temp-buzei. "Same type as documents cleared via F-32
APPEND lt_ftpost.
* Documents to be cleared
lt_ftclear-agkoa = 'D'. "Account Type
lt_ftclear-xnops = 'X'. "Indicator: Select only open items which are not special G/L?
lt_ftclear-agbuk = so_bukrs-low. "Example company code
lt_ftclear-agkon = so_kunnr-low. "Example Customer
lt_ftclear-xfifo = 'X'.
lt_ftclear-selfd = 'BELNR'."Selection Field
lt_ftclear-selvon = wa_bsid_temp-belnr.
lt_ftclear-selbis = wa_bsid_temp-belnr.
APPEND lt_ftclear.
*lt_ftclear-selvon = p_doc2.
*
*lt_ftclear-selbis = p_doc2.
*
*APPEND lt_ftclear.
CALL FUNCTION 'POSTING_INTERFACE_CLEARING'
EXPORTING
i_auglv = l_auglv
i_tcode = l_tcode
I_SGFUNCT = l_sgfunct
I_NO_AUTH = ' '
* IMPORTING
*
* E_MSGID =
*
* E_MSGNO =
*
* E_MSGTY =
*
* E_MSGV1 =
*
* E_MSGV2 =
*
* E_MSGV3 =
*
* E_MSGV4 =
*
* E_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.
IF sy-subrc <> 0.
RETURN.
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 sy-subrc <> 0.
RETURN.
ENDIF.
CLEAR wa_bsid_temp.
ENDLOOP.
ENDFORM.
08-23-2015 1:50 PM
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
08-24-2015 12:31 PM
Hi Venkat,
Thanks for the tips. I used this code but still the solution did not come. I want to use BDC using call transaction for tcode F-51 . Could you provide me a sample code ? I need only using call transaction method since i am calling the recording in the same program.
Regards,
Saurav Lahiry
08-25-2015 7:14 AM
Hi Saurav,
Change the mode from N to 'A' OR 'E' to analysis the missing input.
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' " A OR E.
Hope it helpful,
Regards,
Venkat.
08-25-2015 10:32 AM
Hi Saurav,
Please refer the below link where you can post or park the document by changing the posting keys for the different T-code using BAPI BAPI_ACC_DOCUMENT_POST with the example code.
You just need to implement a simple BTE for this. By using BAPI to post document instead of BDC, You also avoid the future errors.
Let me know if you are still facing any issues.
Regards,
Shadab.