cancel
Showing results for 
Search instead for 
Did you mean: 

Expert PlainFile-To-Idoc(multiple) Sap XI scenario

Former Member
0 Kudos

Hi experts,

We have a PlainFile-To-Idoc Sap XI scenario. We have a requirement where we need to produce multiple idocs from one file. The plainFile(=text file) is similar to this:

> >Header123ABC123 >DetailXYZ987ABC654 >DetailXYZ988CBA653 >DetailXYZ989BCA652 >DetailXYZ989CAB651 >.. >.. >.. >.. >TrailerZYQ474FDJKDF >

Now for every 300 u201Cdetailu201D records from the above structure it should create another idoc.

I already defined in the File adapter the content conversion with the following parameters:

> >Document Name: MT_Prices >Document namespace: http://prices >Recordset Name: Recordset >Recordset Structure: Header,1,Detail,*,Trailer,1 >Recordset Sequence: Ascending >Recordsets per Message: 300 >Key Field Name: KeyID >Kield Field Type: String (Case-sensitive) > >Header.fieldnames >Header.fieldFixedLengths >Header.missingLastfields add >Header.keepIncompleteField YES >Header.fieldFixedLengthType byte >Header.lastFieldsOptional YES >Detail.keyFieldValue >Detail.fieldnames >Detail.fieldFixedLengths >Detail.missingLastfields add >Detail.keepIncompleteField YES >Detail.fieldFixedLengthType byte >Detail.lastFieldsOptional YES >Detail.keyFieldValue >Trailer.fieldnames >Trailer.fieldFixedLengths >Trailer.missingLastfields add >Trailer.keepIncompleteField YES >Trailer.fieldFixedLengthType byte >Trailer.lastFieldsOptional YES >Trailer.keyFieldValue >

The mapping is as follows:

Message Type =

>MT_Prices (1:1)

>>Recordset (1:unbounded)

>>>Header (1:1)

>>>Detail (1:unbounded)

>>>>Field1 (1:1)

>>>>Field2 (1:1)

>>>>..

>>>Trailer (1:1)

External Message ZPRICES =

>ZPRICES (1:1)

>>IDOC (1:unbounded)

>>>BEGIN (required)

>>>EDI_DC40 (1:1)

>>>>SEGMENT (required)

>>>..

>>>..

>>>Z1PRICES (1:1000)

>>>>SEGMENT (required)

>>>>Field1 (0:1)

>>>>Field2 (0:1)

>>>>..

Graphical mapping description:

>ZPRICES is graphical mapped with a constant (which is empty)

>Recordset is graphical mapped with IDOC

>BEGIN is graphical mapped with a constant (which is 1)

>SEGMENT (of EDI_DC40) is graphical mapped with constant (which is 1)

>Z1PRICES is graphical mapped with Detail

>SEGMENT(of Z1PRICES) is graphical mapped with constant (which is 1)

>Field1 is graphical mapped with Field1

>Field2 is graphical mapped with Field2

I place a text file with 1000 detail records pulling into XI. The result is 1 IDoc with 1000 segments.

I expected 4 IDocs: 3 IDocs with each 300 segments and 1 IDoc with 100 segment.

So can you tell us to solve this problem?

Looking forward for your help on this

Thanks in advance

Edwin

Accepted Solutions (0)

Answers (10)

Answers (10)

Former Member
0 Kudos

make; max occurance of the segment feild to 300, and define one global variable for counting the number of segments with that create the next idoc.. also you may have to change the max occurance of IDOC TYPE to unbounded; for changing the maxoccurance, download the IDOC's XSD to file and set maxoccurnace and re-upload as EXTERNAL DEFINATION..

Former Member
0 Kudos

Hi

Here is the mapping

> /ZPRICES=const([value=])

> /ZPRICES/IDOC=collapseContexts(SplitByValue([type=Value changed]ceil(div(index([start=1, inc=1, type=entire document]/ns0:MT_PRICES/Recordset/Detail=), const([value=300])))))

> /ZPRICES/IDOC/@BEGIN=const([value=1])

> /ZPRICES/IDOC/EDI_DC40/@SEGMENT=const([value=1])

> /ZPRICES/IDOC/EDI_DC40/TABNAM=const([value=EDI_DC40])

> /ZPRICES/IDOC/EDI_DC40/DIRECT=const([value=2])

> /ZPRICES/IDOC/EDI_DC40/IDOCTYP=const([value=ZPRICES])

> /ZPRICES/IDOC/EDI_DC40/MESTYP=const([value=ZPRICES])

> /ZPRICES/IDOC/EDI_DC40/SNDPOR=concat([delimeter=]concat([delimeter=]const([value=XI]), iF(const([value=D]), startWith2(receiver(), const([value=BS_DEV])), iF(const([value=Q]), startWith2(receiver(), const([value=BS_QAC])), const([value=P])))), const([value=100]))

> /ZPRICES/IDOC/EDI_DC40/SNDPRT=const([value=LS])

> /ZPRICES/IDOC/EDI_DC40/SNDPRN=concat([delimeter=]concat([delimeter=]const([value=XI]), iF(const([value=D]), startWith2(receiver(), const([value=BS_DEV])), iF(const([value=Q]), startWith2(receiver(), const([value=BS_QAC])), const([value=P])))), const([value=100]))

> /ZPRICES/IDOC/EDI_DC40/RCVPRT=const([value=LS])

> /ZPRICES/IDOC/Z1PRICES=/ns0:MT_PRICES/Recordset/Detail=

> /ZPRICES/IDOC/Z1PRICES/@SEGMENT=SplitByValue([type=Value changed]ceil(div(index([start=1, inc=1, type=entire document]/ns0:MT_PRICES/Recordset/Detail=), const([value=300]))))

> /ZPRICES/IDOC/Z1PRICES/MATNR=/ns0:MT_PRICES/Recordset/Detail/PartNumber=

> /ZPRICES/IDOC/Z1PRICES/PB00=/ns0:MT_PRICES/Recordset/Detail/PurchasePrice=

> /ZPRICES/IDOC/Z1PRICES/PR00=/ns0:MT_PRICES/Recordset/Detail/RetailPrice=

> /ZPRICES/IDOC/Z1PRICES/ZK01=/ns0:MT_PRICES/Recordset/Detail/DiscountCode=

> /ZPRICES/IDOC/Z1PRICES/DATAB=/ns0:MT_PRICES/Recordset/Detail/EffectiveDate=

and the error message

><Trace level="1" >type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: >RuntimeException in >Message-Mapping transformation: Cannot produce target element

>/ZPRICES/IDOC/Z1PRICES[5]/SEGMENT. Check xml instance is valid for source xsd and target-field >mapping fulfills requirements of target xsd at >com.sap.aii.mappingtool.tf3.AMappingProgram.start >AMappingProgram.java:406)

Former Member
0 Kudos

Hi,

yes, indeed, one to one mapping.

i did both ways, but unfortunality the same error.

jyothi_anagani
Active Contributor
0 Kudos

Hi,

Can you please send Complete Error code.

If it is possible please send complete Mapping.

Thanks.

jyothi_anagani
Active Contributor
0 Kudos

Hi,

How did you map these

SEGMENT (required)

Field1 (0:1)

Field2 (0:1)

one to one mapping and for these also change the context or removeContext.

Thanks.

Former Member
0 Kudos

Hi,

Did

>Detail --> removeContexts --> index 1,1,context ---> div ---> SplitbyValue(valuechange) ---> Segment

> Constant 300 --->

and

>Detail (change Context) --> index 1,1,entire doc ---> div ---> SplitbyValue(valuechange) ---> Segment

> Constant 300 --->

and

>Detail --> removeContexts --> index 1,1,entire doc ---> div ---> SplitbyValue(valuechange) ---> Segment

> Constant 300 --->

and

>Detail --> removeContexts --> index 1,1,context ---> div ---> SplitbyValue(valuechange) ---> Segment

> Constant 300 --->

all the same error result.

Former Member
0 Kudos

Hi Jyothi Anagani,

thanks for clearing up your description.

I tested the scenario and I get the following message mapping error

>Cannot produce target element /ZPRICES/IDOC/Z1PRICES[5]/SEGMENT

Any idea why the at fifth segment?

I tested the input into the testmethode in the message mapping area in debug mode.

The following debuginformation is generated

> 13:45:00 Start of test

> u2022 Document start

> u2022 Start tag [ZPRICES]

> u2022 Start tag [IDOC]

> u2022 Add attribute: [BEGIN]=[1]

> u2022 Start tag [EDI_DC40]

> u2022 Add attribute: [SEGMENT]=[1]

> u2022 Start tag [TABNAM]

> u2022 Put value [EDI_DC40]

> u2022 Close tag [TABNAM]

> u2022 Start tag [DIRECT]

> u2022 Put value [2]

> u2022 Close tag [DIRECT]

> u2022 Start tag [IDOCTYP]

> u2022 Put value [ZPRICES]

> u2022 Close tag [IDOCTYP]

> u2022 Start tag [MESTYP]

> u2022 Put value [ZPRICES]

> u2022 Close tag [MESTYP]

> u2022 Start tag [SNDPOR]

> u2022 Put value [XIP100]

> u2022 Close tag [SNDPOR]

> u2022 Start tag [SNDPRT]

> u2022 Put value [LS]

> u2022 Close tag [SNDPRT]

> u2022 Start tag [SNDPRN]

> u2022 Put value [XIP100]

> u2022 Close tag [SNDPRN]

> u2022 Start tag [RCVPRT]

> u2022 Put value [LS]

> u2022 Close tag [RCVPRT]

> u2022 Close tag [EDI_DC40]

> u2022 Start tag [Z1PRICES]

> u2022 Add attribute: [SEGMENT]=[1]

> u2022 Start tag [MATNR]

> u2022 Put value [12345-TEST1]

> u2022 Close tag [MATNR]

> u2022 Start tag [PB00]

> u2022 Put value [49.00]

> u2022 Close tag [PB00]

> u2022 Start tag [PR00]

> u2022 Put value [89.00]

> u2022 Close tag [PR00]

> u2022 Start tag [ZK01]

> u2022 Put value [ND]

> u2022 Close tag [ZK01]

> u2022 Start tag [DATAB]

> u2022 Put value [01052009]

> u2022 Close tag [DATAB]

> u2022 Close tag [Z1PRICES]

> u2022 Start tag [Z1PRICES]

> u2022 Add attribute: [SEGMENT]=[2]

> u2022 Start tag [MATNR]

> u2022 Put value [12345-TEST2]

> u2022 Close tag [MATNR]

> u2022 Start tag [PB00]

> u2022 Put value [49.00]

> u2022 Close tag [PB00]

> u2022 Start tag [PR00]

> u2022 Put value [89.00]

> u2022 Close tag [PR00]

> u2022 Start tag [ZK01]

> u2022 Put value [ND]

> u2022 Close tag [ZK01]

> u2022 Start tag [DATAB]

> u2022 Put value [01052009]

> u2022 Close tag [DATAB]

> u2022 Close tag [Z1PRICES]

> u2022 Start tag [Z1PRICES]

> u2022 Add attribute: [SEGMENT]=[3]

> u2022 Start tag [MATNR]

> u2022 Put value [12345-TEST3]

> u2022 Close tag [MATNR]

> u2022 Start tag [PB00]

> u2022 Put value [49.00]

> u2022 Close tag [PB00]

> u2022 Start tag [PR00]

> u2022 Put value [89.00]

> u2022 Close tag [PR00]

> u2022 Start tag [ZK01]

> u2022 Put value [ND]

> u2022 Close tag [ZK01]

> u2022 Start tag [DATAB]

> u2022 Put value [01052009]

> u2022 Close tag [DATAB]

> u2022 Close tag [Z1PRICES]

> u2022 Start tag [Z1PRICES]

> u2022 Add attribute: [SEGMENT]=[4]

> u2022 Start tag [MATNR]

> u2022 Put value [12345-TEST4]

> u2022 Close tag [MATNR]

> u2022 Start tag [PB00]

> u2022 Put value [49.00]

> u2022 Close tag [PB00]

> u2022 Start tag [PR00]

> u2022 Put value [89.00]

> u2022 Close tag [PR00]

> u2022 Start tag [ZK01]

> u2022 Put value [ND]

> u2022 Close tag [ZK01]

> u2022 Start tag [DATAB]

> u2022 Put value [01052009]

> u2022 Close tag [DATAB]

> u2022 Close tag [Z1PRICES]

> u2022 Start tag [Z1PRICES]

> Cannot produce target element /ZPRICES/IDOC/Z1PRICES[5]/SEGMENT. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd

> Cannot produce target element /ZPRICES/IDOC/Z1PRICES[5]/SEGMENT. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd

> 13:45:00 End of test

jyothi_anagani
Active Contributor
0 Kudos

Hi,

change the context of details or after details use removeContext. Then you will not get this Error.

Thanks.

jyothi_anagani
Active Contributor
0 Kudos

Hi,

inputsegment = details in your Source structure.

target Message = IDOC in your Target Structure

target Segment = Z1PRICES in your Target Structure

any doubt regarding this let me know.

Thanks.

Former Member
0 Kudos

Hi Jyothi Anagani,

I don't know what you mean with inputsegment and target MessageType , because i don't have them

Which targetsegment you mean, there are 2 kindsof Segments (as shown)?

Hi hemant gupta,

what is different what I already did and what you descibed?

Thx for the response you all.

Greetings, Edwin

Former Member
0 Kudos

Hello,

U can break the file at the Sender adapter. Use module and after every 300 details break that file and send to Message Mapping.

Use file content Conversion and u will have option to break the file there.

There in recordset structure give : H 1 D 300

Former Member
0 Kudos

Here either give document name or record setname: Both will same ur message type name.

jyothi_anagani
Active Contributor
0 Kudos

Hi,

Please Do Mapping like this,


details----->removeContext---->index(1)------>div------>ceil------->splitByValue(value Change)------>collapseContext------>IDOC
                    constant(300)/


details----->removeContext---->index(1)------>div------>ceil------->splitByValue(value Change)------>Z1PRICES
                    constant(300)/

What will happen is it will give index to every segment and we are dividing that index by 300,no.of records are 1000.So 1000 indexes come.Each one dividing by 300. and ceiling after collapse context we will get queue like


1
2
3
4

like that for each value one msg type and each message will carry only 300 segments

Thanks.