cancel
Showing results for 
Search instead for 
Did you mean: 

Last record

Former Member
0 Kudos

Dear All

I have a requirement in an file to idoc scenario where i have to do the mapping based on whether the current record in the file is last or not.

If the current record is the last I have to put a constant value to a field in idoc or else i have to map another constant to the same field.

I am not able to figure how to find whether the current record is the last one or not.

please help me out.

Sourabh

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

use the count function to get the total occurance.

The use the index function. It will give you the current index of a record.

So your logic should be if count = index then it is the last record.

Ref:

https://wiki.sdn.sap.com/wiki/display/XI/CountofRecords-%27Countontheeasiestway+through%27

Former Member
0 Kudos

Hi

Actually I am having a flat file which contains a number of records. Each record has to be maaped to the idoc. My requirement is that how will I find which perticular record in the file is the last one.

Former Member
0 Kudos

Sourabh Nirmal

The same still applies. If you are mapping a file ot IDOC where you are submitting the IDOC's in a packet 1..n then on the secific field (you mentioned it was a feld meaning one field) you need to check:

RecordSet

Record -


> IDOC

SrcField IF (count(Record) = Index(Record)) ---> Const1 destField

ELSE -


> Const2

The condition in the IF although applied to every line in the file will only hold true on the last line.

Thanks

Damien

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sourabh

maybe 2 options:

1. if you do an xslt this is easy:

<xsl:if test="position()!=last()">

.......

</xsl:if>

2. In a graphical mapping use the index and count functions:

If (index == count)

Then set Constand

Thanks

Damien