Hi Meryam,
Thanks for sharing your script. I took a quick look, and there are some things to change/fix:
- the SAVE (ok code = BU) should be outside of the loop
- you hit enter after entering the header information, but you didn't give it a line item or go into FAST ENTRY on the top menu - it's lost from then o
Please see the step by step guide here: https://help.precisely.com/r/Automate-Studio/20.3/en-US/Automate-Studio-with-Connect-User-Guide/Transaction-Module-Guides/FB01-step-by-step_-Posting-documents
It's best to enter the header information, go into fast entry and then fill in details. Make sure you record one of each type of entry - as some have more costing/copa fields than others so that you can capture as many of the fields as possible. Then Save outside of the loop.
And also an example that uses this approach here with Transaction for FB01: https://community.precisely.com/viewdocument/post-document-1?CommunityKey=e1f0c200-ca7e-46e7-b5c7-01855e5120c7&tab=librarydocuments
The only other thing is that sometimes you will have fields in the detail view and sometimes you will not based on the GL account type. You may have to use IF statements, for example: IF Column G (GL account) begins with 6 or Column G begins with 5 THEN include the input fields. Only you will know what fields exist.
Also, FB50 does allow you to enter all of the detail fields. If you go into details on a line item and then click on Profit Segment (for the COPA fields), you will see many:

Lastly if you want to take the interface out of the equation, you can use a BAPI, like this: https://community.precisely.com/viewdocument/bapi-acc-document-post-1?CommunityKey=e1f0c200-ca7e-46e7-b5c7-01855e5120c7&tab=librarydocuments
It includes a set of COPA fields, and you can copy and paste that section in Expert mode to add/remove them, but you have to know the technical field names.
I hope this gives you a set of ideas that will give you a choice on what will work best for you.
Best Regards,
Sigrid
------------------------------
Sigrid Kok
Precisely Software Inc.
------------------------------
Original Message:
Sent: 04-19-2024 05:32
From: Meryam KHOUBBAZ
Subject: Winshuttle pour la comptabilisation de piéces par FB01
Hello Sigrid,
First of all, thank you all for you quick response and for your help, i will try to answer you on english even if it is not verry well :p
Actually why we cannot use FB50 instead of FB01, is because the first tcode is verry limited. We can only enter general account documents and not other type of account like auxiliary customer, supplier or material ... i uploaded the current obtained script that actually does not worked even with plenty of attemp. ANY HELP PLEASE!?
------------------------------
Meryam KHOUBBAZ
Asian Infrastructure Investment Bank
NJ
------------------------------
Original Message:
Sent: 04-08-2024 09:58
From: Sigrid Kok
Subject: Winshuttle pour la comptabilisation de piéces par FB01
Bonjour Maryam,
My French is bad, so I will reply in English.
There is an example template here: https://community.precisely.com/viewdocument/post-document-1?CommunityKey=e1f0c200-ca7e-46e7-b5c7-01855e5120c7&tab=librarydocuments You must join the SAP Module Templates community to view it.
As Jan suggests, the BAPI or even FB50 are easier than FB01, because the fields change on the details of each line item depending on the type of account.
I hope the example helps.
Best Regards,
Sigrid
------------------------------
Sigrid Kok
Precisely Software Inc.