cancel
Showing results for 
Search instead for 
Did you mean: 

How to count detail line in a flat file.

0 Kudos

I have a flat file which has multiple header and detail lines. This flat file will later mapped to ACC_DOCUMENT03 IDOC and post it to SAP.

-doc1

-


header

-


cocode

-


docdate

-


postingdate

-


currencycode

-


detail

-


glaccount

-


itemno

-


costcenter

-


detail

-


glaccount

-


itemno

-


costcenter

I need to have a counter to track the number of detail lines in ACC_DOCUMENT03 IDOC target field in ITEM_TEXT.

for example this is the flat file

HDR,US00,20080102,20080102,USD

DTL,32456,1,CC0001

DTL,32456,2,CC0001

HDR,US00,20080102,20080102,USD

DTL,32458,1,CC0002

DTL,32458,2,CC0002

HDR,US00,20080102,20080102,USD

DTL,32459,1,CC0001

DTL,32459,2,CC0001

So every detail line in ITEM_TEXT, I need to put 1,2,3,4,5,6 and so on.

I tried to use global container to keep track the line counter but it doesn't work. Can anyone please help?

Edited by: Kam Weng Leong on Mar 8, 2009 1:58 AM

Edited by: Kam Weng Leong on Mar 8, 2009 2:00 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

VijayKonam
Active Contributor
0 Kudos

You can use Count function in the message mapping to populate.

VJ

0 Kudos

It doesn't work. It is not that simple dude.

Edited by: Kam Weng Leong on Mar 28, 2009 3:28 AM

Former Member
0 Kudos

Hi Kam,

I believe, u can use xslt mapping for this where u can use count function for each 'details', whenever it find details tag it will increment the counter for details field. which u can add in the output file. After that you can try message mapping if required.

I believe it will work.

regards

ram

0 Kudos

I guess the xslt approach make sense but unfortunately it's complicated and cumbersome. Finally, I ask the source file to send me the counter.

I'd expect XI to have a global counter that can count on the root level.

I'm closing the thread as it has been linger here for some times.