cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi All,

I have a requirement where in i need to add one file header to a file in append mode .

The requirement is as follows :

In a day , SAP sends certain number of IDOCs to XI . For the first IDOC that comes in ,XI has to create a file and later for the rest of the IDOCs ,XI just has to append the file content .

- At the End of the Day , the target system picks this file for processing.

My file structure is as follows:

File Header

seg1

seg2

seg3

seg1

seg2

seg2

seg3

seg3

While creating a file in append mode at receiver , the header record gets appended multiple times which is not desirable.

Please suggest me ways to make sure that the file gets written in the above format with the file header only once .

Thanks for your help,

Pooja

0 Likes
View Entire Topic
arkesh_sharma
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Pooja,

This is just a suggestion. Please let me know if this doesn't suit you.

Suggestion:

Create a Global container variable. Set the value as false by default. When the value comes in PI for the first time, pass the header data and set the value of global variable as true and start a timer in the UDF itself which will keep track of time. For every consecutive record, check the value of the global variable if it is true/false. If it is true then do not map the header data. Reset the value of the global variable to false when the timer reaches a value of 24 hours (say for example).

Thanks,

Arkesh

ambrish_mishra
Active Contributor
0 Likes

Hi Arkesh,

AFAIK, the value of a global container is persisted till the execution of a mapping nor will a UDF work beyond a message execution.

Here the requirement is to see through multiple message executions and append Header only once while trying to avoid a BPM solution.

Ambrish

PS: I don't comment on alternate solutions but don't want Pooja to get confused here.

arkesh_sharma
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Ambrish,

Thank You for responding to my comment.

My comment was based on a blog (http://scn.sap.com/people/gabrielsagayaselvam.panneerselvam/blog/2011/05/05/jdbc-lookup-optimization) but missed on the persistence point.

Thank You for pointing that out. I will keep that in mind.

Thanks,

Arkesh