2009 Sep 21 7:44 PM
Hi All,
I have a requirement to add segments to idocs that are already in the database. I had hoped to use Function Group EDI1 to do so, but the FM EDI_SEGMENTS_ADD_BLOCK only works for creating idocs from scratch. There is a FM EDI_CHANGE_DATA_SEGMENTS, but it appears to only allow changing segments that already exist, not adding new segments.
How would you handle this one? This is the first time I've been tasked with adding segments to an idoc OUTSIDE of a user exit during create, and I'm unsure how to proceed.
Thanks,
Bryan
2009 Sep 28 9:59 PM
Anybody?
At this point I'm thinking I just need to create a new idoc as a copy of the old, and set the old to a status that will keep it from being picked up.
2009 Sep 21 10:28 PM
Are you planning to add a custom segment or standard segment?
2009 Sep 21 10:32 PM
If it is standard IDoc segment, i am sure you can use this FM
FU EDI_SEGMENTS_ADD_BLOCK
____________________________________________________
Short Text
EDI interface: Add block of data records
Each call of the function module 'EDI_SEGMENTS_ADD_BLOCK' inserts a block of data records into the IDoc. In each case the EDI interface records the current position in the IDoc and appends the block of records at the end.
The data records are transferred to the function module in an internal table. This table is NOT initialized in the function module, that is, the parent program must carry out an initialization (REFRESH) during a repeated call.
Application data is transferred to the data record. The data record consists of a general administration part and of the field 'SDATA', which contains the application data.
The administration part contains information that describes the data record in the context of the Intermediate Document (for example, the IDoc number).
The fields 'SEGNAM' and 'HLEVEL' must be filled by the parent program.
The fields 'SEGNUM' and 'PSGNUM' can be filled by the function module or can be transfered during the function module call. They are checked for consistency in this case.
With the help of an ABAP/4 Dictionary structure, the field 'SDATA' can be split up and interpreted. The documentation for these structures can be found using the program 'RSEIDOC1'.
The function module can only be called in 'CREATE' mode.
Parameters
IDENTIFIER
IDOC_CONTAINERS
Exceptions
IDENTIFIER_INVALID
IDOC_CONTAINERS_EMPTY
PARAMETER_ERROR
SEGMENT_NUMBER_NOT_SEQUENTIAL
Function Group
EDI1
2009 Sep 22 1:35 PM
They're standard segments. I'm not trying to edit the structure of an idoc, I'm trying to add to the contents of an IDOC.
I found that FM too - it's in my opening post. The problem with that FM is:
The function module can only be called in 'CREATE' mode.
I'm trying to add segments to IDOCs that are already in the database, not create them from scratch.
Thanks
Bryan
2009 Sep 23 1:29 PM
Hi Bryan,
Do you want to EDIT the IDoc contents when IDoc is already created in database?
You can use FM 'EDI_DOCUMENT_OPEN_FOR_EDIT' to change contents of IDoc / add segments in IDoc.
Regards,
Mahesh Pakhale
2009 Sep 23 2:07 PM
Yes, EDI_DOCUMENT_OPEN_FOR_EDIT opens an idoc so you can edit it.
BUT, once you have it open, you can't add segments. You can change segments using EDI_CHANGE_DATA_SEGMENT(S), but that FM does not allow you to add segments, only to change existing segments.
2009 Sep 28 9:59 PM
Anybody?
At this point I'm thinking I just need to create a new idoc as a copy of the old, and set the old to a status that will keep it from being picked up.
2009 Oct 06 1:30 PM
Hi Bryan,
I have the same requirement. And I also concluded the same thing instead of editing the existing IDoc, create new one.
2009 Oct 06 2:59 PM
Hi,
I'm not sure what will you achieve by adding data to existing processed IDoc? It will anyways not process once again ( if they are in status 53). The, only way to achieve this is to fetch the existing IDoc data in a internal table of type edidd( FM IDOC_READ_COMPLETELY), add data to it and processs a new IDoc altogether.
Yes, if you set the status of the old Idoc to 68, it will not be processed again. You can use function module IDOC_STATUS_WRITE_TO_DATABASE for the same.
Br,
Advait
2009 Oct 07 3:40 PM
I'm not trying to add the data to an existing PROCESSED idoc, I'm trying to add it to an existing idoc that has not yet been processed.
I'm unable to add the data during a user exit while the idoc is being created (for functional reasons I won't bother to go into here) so I need to add it after the idoc has been created. Sadly, it looks like the only way is to delete and re-create with the extra segments.
I'll leave the question open for a couple more days until I actually finish with the code in case anyone else has ideas.
2009 Dec 02 8:10 PM
Looks like there is no way to do this. I changed my code such that it deletes the old idoc and creates a new one with the new segments.
Just wanted to post an update in case someone else comes looking for a solution.