Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

f-02 uploading

sanjeev_mishra_15aug
Active Participant
0 Likes
2,198

Hi experts,

Please guide me that

How to put all the line items with same header data or contents into single document no. i.e. belnr while uploading data using call session method in BDC, because the mentioned field is systematically generated once the data is uploaded into DB table...

Please put some logic in coding here.

Thanks in advance...

1 ACCEPTED SOLUTION
Read only

archanapawar
Contributor
0 Likes
2,034

your question is not clear. Please explain what you need exactly.

10 REPLIES 10
Read only

archanapawar
Contributor
0 Likes
2,035

your question is not clear. Please explain what you need exactly.

Read only

0 Likes
2,034


Thanks Archana for ur reply,

I tell you what exactly I want in my program,

I have to upload contents from an excel file having following fields:

BKPF table: BLDAT, BLART, BUKRS, BUDAT, WAERS, KURSF, WWERT, XBLNR, BKTXT

BSEG table: BSCHL, HKONT, UMSKZ, WRBTR, DMBTR, KOSTL, PROJK, AUFNR, PRCTR, SGTXT

Now I have to put the logic before inserting the contents from all the header data for the above mentioned condition i.e. All line items with same header data will be posted in one document(BELNR). If data in fields from BKPF table are same, treat it as a single document (BELNR).

I hope now I am clear to you....

So please send me some logic for this.

Thanks in advance....

Read only

0 Likes
2,034

Hi Sanjeev,

Once you upload excel file into your internal table, you can use BAPI 'BAPI_ACC_DOCUMENT_POST' to upload data. It is better to use BAPI istead od BDC.

For, BDC, you need to goto tcode SHDB and do the recording of F-02 tcode and generate recording. On that basis you can write your code.

But, this requirement can be achieved using BAPI.

Read only

0 Likes
2,034

Thanks Archana,

Can you please mention it in detail? I meant to say that whether this BAPI will work automatically for the mentioned condition or shall I have to put some logic for that?

Thanks in advance....

Read only

0 Likes
2,034

Offcourse you need to code, you need to pass correct parameters to this BAPI, then only it will work.

You can refer below link, it explains how to use this bapi.

http://wiki.scn.sap.com/wiki/display/Snippets/Vendor+Invoice+Posting+using+BAPI

You will have to pass your data in internal table to the BAPI.

Read only

0 Likes
2,034

Hi Archana,

I went through your link but unfortunately I couldn't get the idea where exactly and what exactly logic I should put in the referred program to fulfill my condition as I mentioned earlier. I again mention you that the document no. i.e. BELNR is systematically generated. So I need to put all the line items with same header data into same Document No..

Ur suggestion is most valuable. Please suggest me. Thanks.

Read only

0 Likes
2,034

Hi Sanjeev,

You will need to develope a program, where you will upload your excel file using FM, get the data into internal table. Once, you have your excel sheet data in internal table, fill the data into work area and tables mentioned in BAPI. E.g. In below example, header data should be passed to w_header. account details to t_item_gl, currencies to t_item_curr. When you execute the program, you will get success or error message in t_return in BAPI.

  CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
     documentheader = w_header
  IMPORTING
     obj_type = g_obj_type
     obj_key = g_obj_key
     obj_sys = g_obj_sys
  TABLES
     accountgl = t_item_gl
     currencyamount = t_item_curr
     return = t_return.

I hope below link will give you idea of how this BAPI works. It is explained with different transaction, but same BAPI can be used for F-02 posting as well. At the end of the document, code snippet is also attached.

http://www.saptechnical.com/Tutorials/BAPI/FI/Index.htm

Read only

0 Likes
2,034

Thanks Archana,

I went through the link of saptechnical website too...

My only querry is that whether I use BDC or BAPI, how to bundle all the line items with same header data into single document. i.e. BELNR.

for this particular condition which logic I need to put. I am not getting the exact idea for this condition only in any of the link you sent me. Please give me any link or any idea through which I can fulfil the given condition.

I hope u understand my real requirement.

Read only

0 Likes
2,034

Per document you want to create you call the bapi. (or the bdc functionality, does not make a difference)

In w_header there will be the header data and in the tables t_item_gl and t_item_curr holds the data of the "Bundled" line items (as you call it).

So in your programm YOU need to bundle these line items that you want in one document and call the bapi or bdc with this set. After succes you can call the bapi/bds with the next set of header and items that need to go in one document.

Hope it is clear now..

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,034

Just use a basic LOOP/AT logic in your code


SORT itab BY (bkpf field lists) " insure those are the first fields of the structure

LOOP AT itab ASSIGNING <fs>.

  AT NEW (last field of bkpf)

     " prepare new document

  AT END.

  " prepare and add an item to document

  AT END OF (last field of bkpf)

     " call BAPI_ACC_DOCUMENT_POST or bdc or POSTING_INTERFACE_DOCUMENT...

  ENDAT.

ENDLOOP.

Regards,

Raymond