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

Document Splitting

Former Member
0 Likes
1,908

I need to post a financial document in SAP from PI. I need to split that document after the 999 Th line. Can anyone help me with the splitting logic?

9 REPLIES 9
Read only

Former Member
0 Likes
1,467

Hi,

How you are posting the Invoice, Are you using BAPI?

Read only

0 Likes
1,467

Yes i am using BAPI. It is a custom BAPI which is doing the posting.

Read only

Florian
SAP Champion
SAP Champion
0 Likes
1,467

Where is the problem?

Just use a counter and after the 999 line set your pointer to the next internal table.

And this isn't a question right now. What document do you got. is it an XML or already in another table stored or or or.

Please share more about the details you are into and I think you will get some useful answers in case my answer didn't help you out

Regards

Florian

Read only

atul_mohanty
Active Contributor
0 Likes
1,467

Hi - What type of  financial document is it ( like GL Posting) ?

Read only

0 Likes
1,467

yes its GL posting. I am done with the splitting part. I wanted to know how to add the debit credit adjustment (GL account)in the 998th line and keep the final result in the 999th line. The final internal table is it_out. I am using BAPI_ACC_DOCUMENT_POST.

Read only

0 Likes
1,467

Hi Tina

In such scenario we normally have a dummy GL account GL1. Lets say till 998 lines the total is 50 Credit we add 999 line for GL1 account with 50 Debit and post the document. The next document has first line as GL1 credit 50 and then other lines. So effectively dummy GL account balances out

Nabheet

Read only

0 Likes
1,467

Hi Nabheet

I get the concept but I am nnot sure in which field to append it.? and how do I know for sure it will be the 998th line item?

Read only

0 Likes
1,467

Because you can read the sy-tabix or sy-index. It just depends if you loop or make a do...

Regards

Florian

Read only

0 Likes
1,467

Hi Tina -

Say if you have 1200 Lines to be posted then you will create two account documents. The First Accounting document will have 998 Lines + 1 Line for Dummy GL and 2nd document will have 222 Lines + 1 Dummy GL.

1. Now  loop over the 1200 lines. Put a counter and  another variable for sum of the amounts.

2. When the counter reaches 998 then check the sum of amounts.

(a)If its credit (negative) then post a debit to the dummy GL as the line 999. So the balance will be zero.

(b) If its debit (positive then post a credit to the dummy GL as the line 999.). So the balance will be zero.

(c) then you call BAPI_ACC_DOCUMENT_POST to create first accounting document

3. Now you need create 2nd account document. If you posted the dummy GL as negative in step 2 above then create the 1st line as positive for dummy GL else create the 1st line as negative for dummy GL.

4. Proceed for the rest of line items and create till 1200 lines. ( the 2nd document should have 221 lines )

5. Then you call BAPI_ACC_DOCUMENT_POST to create 2nd accounting document  .

Let us know if it helps.

Regards,

Atul Mohanty