Skip to Content
-1

looing the header data and item data based on posting key

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

reimb-pay-1.txt (2.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Mar 24 at 01:47 PM

    Hi Bhavani Amara,

    Add one more column in excel and mention H and L as a indicator, load to respective Internal Table and proceed.

    Regards

    Abinath. S

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 28 at 06: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.
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.