cancel
Showing results for 
Search instead for 
Did you mean: 

Key field value is the same in Header and Footer

Former Member
0 Kudos

Hi,

Im doing a flat file(Fixed Length File) to a IDOC scenario where My key field value(The first field in the record which is always constant) is the same in case of Header and Footer.I have mapping for both Header and footer than how can i do the mapping.The details that i specified are as follows:

Recordset_Structure :: Header_record,1,Data_record,*,Footer_record,1

Can anyone help me in this regard.

Thnaks and Regards,

Bhargav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bhargav !

You could do this: if your header and footer structures don't have any other piece of data that could be use as keyfield, then you could declare in content conversion only 2 structures, one for "detail" and one for "header/footer"...let's call it "special"

you will get in mapping a structure like this:

special

- rec1s

- rec2s

detail

- rec1d

- rec2d

- rec3d

- recNd

Then in mapping, using an advanced udf "getHeaderField" that receives the whole queue of the field recNs and gets only the first value, that is with index=0 of the queue.. then other udf "getFooterField", that receives the same, but gets only the last value, that is with index = queue.length-1..then use this both udfs for each field in header and footer structures to map to the target.

Is it clear?

Regards,

Matias.

Former Member
0 Kudos

Hey Maitias,

Thanks-you for the same.Can u also please suggest me what to do when the Key value is different for the Detail Record.I get "1" or "2" as the Key Field value and the details record does contain many other fields.It can be one or two.Any suggestions on the same.

Thanks and Regards,

Bhargav

Former Member
0 Kudos

Hi Bhargav !

Do you mean, that there is no unique value to identify a detail type of record..let's say, all records with value "1" or "2" in field "KeyField", should be detected as details records..is that right??

For this, you could duplicate the declaration in the file content conversion in file adapter communication channel. Once for the detail record with keyfield value = 1 and once for the detail record with keyfield value=2..also use the same names... e.g.

detail.fieldNames = a,b,c,d

detail.keyFieldValue = "1"

detail.keyFieldValue = "2"

Regards,

Matias.

Former Member
0 Kudos

Hi,

I have done that also.But then it is only taking the first declared key field value and that corrresponding record structure is generated and it is eliminating the records with the second key field value.

Thanks,

Bhargav

Former Member
0 Kudos

Hi Bhargav !

Check this:

Maybe it could help.

Regards,

Matias.

Former Member
0 Kudos

Hey Matias,

I the first scenario where my header and footer records have the same keyfield value, i have used your suggestion but what if the header record has fields that has to be mapped to another field in the IDOC.Than how can i do that.Any help on this?

Thnaks,

Bhargav

Former Member
0 Kudos

Hi Bhargav !

My approach uses the index of the value in the mapping queue to detect if it is the header or the footer, taking in account that the header appears first, footer appears last, and there is only one recordset per message. If you have more than 1 recordset per source message, your header fields udf should get the 1st, the 3rd, the 5th, etc. record, all the odd index records..they should be the headers...then the even index record should be the footers..

Regards,

Matias.

Former Member
0 Kudos

Hi,

If i do according to the suggestion given by you than the output comes in this manner

my input is

<header>

-


<inp1>123</inp1>

-


<inp2>hello</inp1>

</header>

<header>

-


<inp1>123</inp1>

</header>

where the second occurance of the header is "Footer".But my task here is that i have to map the Inp2 field of the header to an output field 'op1'of an IDOC which is created as many times as the details record occurs,but here im able to get only op1 field in the output only once.How can i solve this issue.Please help me out in this its very urgent for me now.

Thanks,

Bhargav

Former Member
0 Kudos

Hi Bhargav !

If I understand correctly, then you need to use the mapping function "useOneAsMany", this function has 3 input parameters. Please check the SAP documentation on this function. Basically, the first parameter should be the value that you have once and need to repeat, that should be the inp2 field of the header, the 3rd parameter is to state "how many" times should be repeated..then you should use here the 0/1..unbounded tag of the detail...maybe using the same input in 2nd and 3rd parameters it could work...it should output the first parameter value as many times as values are in the 3rd parameters.

Regards,

Matias.

Former Member
0 Kudos

Hi,

Thank-you It solved the problem.Can i have ur mail-id.:) So that i can contact a technically sound person like u in future as ima newbie it would be of great help to me.

Bhargav

Former Member
0 Kudos

Hi Bhargav !

Great !! my email is matiwork@gmail.com. Anyway, you should also check this forums, you will get different answers and point of view of the same problem, it is a great resource.

Please remember to mark this thread as answered and give points!

Regards,

Matias.

Answers (0)