03-24-2020 7:30 AM
Hi,
how to do looping for header data and item data for bdc
i attached my excel file for that file i want to upload into sap system through bdc .
But can you please help me to find out what are header data and item data in that excel file and how to loop the header data as well as item data based on posting key
03-24-2020 7:41 AM
Hi Bhavani,
I remember you had similar BDC issues you raised couple of weeks before. Is this the same issue or different.
I would suggest BAPI instead of BDC - which will be convenient to handle.
Please update
Let me know if you need any help on BAPI - I can provide you with model template
03-24-2020 1:47 PM
Hi bhavani123,
Add one more column in excel and mention H and L as a indicator, load to respective Internal Table and proceed.
Regards
Abinath. S
03-24-2020 1:54 PM
I can't understand your question at all. You don't even tell what transaction you call.
If you want people to create the program for you (for free), please provide the specification. Crystal balls don't work with programming.
03-28-2020 4:57 AM
Hi Krishnamurty Sir,
As you said that can you please provide model template for bapi
03-28-2020 6:03 AM
Dear Bhavani,
I would suggest you to go for the BAPI. Use the following steps and code - which is working code for me. You adjust it according to your dataset.
Step 1 : Declare Data
DATA : header TYPE bapiache09,
customer TYPE bapiacpa09,
docno TYPE bapiache09-obj_key,
accountgl TYPE STANDARD TABLE OF bapiacgl09 WITH HEADER LINE,
accountar TYPE STANDARD TABLE OF bapiacar09 WITH HEADER LINE,
currencyamount TYPE STANDARD TABLE OF bapiaccr09 WITH HEADER LINE,
taxline TYPE STANDARD TABLE OF BAPIACTX09 WITH HEADER LINE,
return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE,
creditcard TYPE STANDARD TABLE OF bapiacpc09 WITH HEADER LINE,
msg TYPE c LENGTH 50.
You may arrange and call like this....
PERFORM debit_entry_cc.
PERFORM credit_entry_cc.
PERFORM bapi_gl_posting_cc.
Step 2 : Populate Debit Items
FORM debit_entry_cc .
DATA lin TYPE int4.
DATA saknr TYPE ska1-saknr.
dr = 0.
LOOP AT it_finalposting_cc INTO wa_finalposting_cc.
IF wa_finalposting_cc-bschl = '40'.
lin = lin + 1.
accountgl-itemno_acc = <item number> "here it goes like 10,20,30 etc
saknr = wa_finalposting_cc-hkont.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = saknr
IMPORTING
output = saknr.
accountgl-gl_account = saknr.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = <your documen ttype>
accountgl-item_text = <your text>
accountgl-alloc_nmbr = wa_finalposting_cc-zuonr .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_finalposting_cc-kostl
IMPORTING
output = wa_finalposting_cc-kostl.
accountgl-costcenter = wa_finalposting_cc-kostl.
APPEND accountgl.
currencyamount-itemno_acc = <item number> " same item number you mentioned above
currencyamount-currency = 'SAR'.
currencyamount-amt_doccur = wa_finalposting_cc-debit.
APPEND currencyamount.
dr = dr + wa_finalposting_cc-debit.
CLEAR : currencyamount, accountgl.
ENDIF.
CLEAR : currencyamount, accountgl, wa_finalposting_cc.
ENDLOOP.
ENDFORM.
Step 3 : Populate Credit items
FORM credit_entry_cc .
DATA lin TYPE int4.
DATA saknr TYPE ska1-saknr.
cr = 0.
LOOP AT it_finalposting_cc INTO wa_finalposting_cc.
IF wa_finalposting_cc-bschl = '50'.
accountgl-itemno_acc = <item number> "importnt cr
saknr = wa_finalposting_cc-hkont.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = saknr
IMPORTING
output = saknr.
accountgl-gl_account = saknr.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = <your documen ttype >.
accountgl-item_text = wa_finalposting_cc-sgtxt .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_finalposting_cc-kostl
IMPORTING
output = wa_finalposting_cc-kostl.
accountgl-costcenter = wa_finalposting_cc-kostl.
accountgl-alloc_nmbr = wa_finalposting_cc-zuonr .
APPEND accountgl.
currencyamount-itemno_acc = <item number> " same item mentioned above importatnt cr
currencyamount-currency = 'SAR'.
"since credit items - multiply by -1
currencyamount-amt_doccur = wa_finalposting_cc-credit * -1.
APPEND currencyamount.
cr = cr + wa_finalposting_cc-credit.
CLEAR : currencyamount, accountgl.
ENDIF.
CLEAR : currencyamount, accountgl, wa_finalposting_cc.
ENDLOOP.
ENDFORM.
Step 4 : Call BAPI
FORM bapi_gl_posting_cc .
header-username = sy-uname.
header-header_txt = 'Payroll Posting'.
header-comp_code = '1000'.
header-doc_date = sy-datum
header-pstng_date = sy-datum
header-doc_type = <your document type goes here>.
header-ref_doc_no = '1'.
"
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = header
IMPORTING
* OBJ_TYPE =
obj_key = docno
* OBJ_SYS =
TABLES
accountgl = accountgl
* ACCOUNTTAX = taxline
currencyamount = currencyamount
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = return.
IF docno IS NOT INITIAL AND docno NE '$'.
CONCATENATE 'Document ' docno+0(10) 'Created' INTO msg SEPARATED BY space.
MESSAGE msg TYPE 'S' DISPLAY LIKE 'I'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
MESSAGE 'Please Refer to Final Posting Tab..!' TYPE 'S' DISPLAY LIKE 'S'.
ENDIF.
ENDFORM.
04-09-2020 6:08 AM