cancel
Showing results for 
Search instead for 
Did you mean: 

Generate multiple idocs based on field value

Former Member
0 Kudos

Hi Friends,

I have a mapping requirement.I want to generate multiple idocs if a source segment X appear multiple times in the message and if X segment having field WERKS value start with P.

If X segment appear multiple times in source and field WERKS doesn't start with P, then dont create multiple idocs at target side.

I want to check WERKS value as P only for the first X segment,as if 1st segment contain WERKS value as P all other X segments in the message have same value by default.

Please help me with the complete mapping flow.

Thanks !!

Suresh.

Accepted Solutions (1)

Accepted Solutions (1)

former_member200962
Active Contributor
0 Kudos

Use the below mapping logic:

WERKS --> StartsWith (P) --> If (Then X) --> TargetIDOC_Node.

Blogs are given in your previous question on how to change the occurence of target IDOC strcuture....procedure will be similar

Regards,

Abhishek.

Former Member
0 Kudos

Hi Abhishek,

Thanks for the information !!

I have implemented the mapping logic provided by you. But this mapping is still not complete.

I wantt to generate multiple idocs at the target side whenever in the segment X the WERKS value is P.

But, whenever this condition satisfies the target multiple idocs should contain the same data of the parent nodes but the X segment data should vary based on the data multiple X segments in source.

For this i think i have to map source X with target X by using splitbyvalue. However i dont know how to fill the condition here.

Pls help !!

Regards,

Suresh.

Former Member
0 Kudos

You can use [useOneAsMany|http://help.sap.com/saphelp_nw04/helpdata/en/ef/df564b6aa24fc9ab0d685460747de5/frameset.htm] to achieve that.

Former Member
0 Kudos

Hi Soumen,

I need to UseOneAsMany to map what.

Is it with source WERKS with target X or source X with target X.

Regards,

Suresh.

Former Member
0 Kudos

Latter one(Source X with target X). The fields in repeating IDOCs whose value needs to be same.

Regards

Soumen...

former_member200962
Active Contributor
0 Kudos

I think useOneAsMany will fail as there is no field in the source with 1..1 occurence .... all the fields are repeating and hence the node function will throw an error saying more values found ..... if the source node ossurs just once in the entire message and you want to put that into the appropriate target nodes (repeatitive) then use the above function......otherwise as Suresh thought use the splitbyvalue.

Regards,

Abhishek.

Former Member
0 Kudos

Hi Avishek

Here useOneAsMany is to be used for header values of IDOC only i.e CONTROL records if I am not mistaken and in that all the fields are either 1...1 or 0..1.

Please correct me if am wrong.

Regards

Soumen...

Former Member
0 Kudos

Hi Experts,

I have mapped

1)WERKS(present in X segment) > StartsWith ('P'constant)-remove context--> If (Then X) --> WMMBXY( Target top node)

2) Source X with target X using Splitbyvalue(each value).

Now when i test the mapping with payload having WERKS as P and 3 'X' segments, i am getting the error

"cannot produce target element /ns0:Messages/ns0:Message1/WMMBXY[2]/idoc"

Please help !!

Regards,

Suresh.

Former Member
0 Kudos
1)WERKS(present in X segment) --> StartsWith ('P'constant)---remove context--> If (Then X) --> WMMBXY( Target top node)

Try this:

WERKS(mapByDefault-blank constant)-> StartsWith('P'constant)-remove context> If ( Then X->splitByValue)-->Target node.

2) Source X with target X using Splitbyvalue(each value).

Try this using useOneAsMany and splitByValue:

1st input(to useOneAsMany) would be the source field(from source header) and 2nd & 3rd inputs(to useOneAsMany) would be the repeating node in source message. Then use a splitByValue(Each Value) and map it to target field.

Hope this helps..

Regards

Soumen...

Answers (2)

Answers (2)

Former Member
0 Kudos

thanks for all the information !!

Now i have created the below mapping to whole structure except to the segment X and its fields where based on which multiple idocs need to get generated.

Source field>mapwithdefault----/

segment(X)-useoneasmany->target field

segment(X)\

Now i am trying to set the condition with source X segment with target top node.

I provide the requirement again:

If source field(in segment X) stars with P,then create multiple idocs at target (with same data in each idoc,only segment X changes)

WERKS(present in X segment) > StartsWith ('P'constant)-If (Then X,Else top source node) --> WMMBXY( Target top node).

With the above mapping multiple idocs are not generating.

Suppose if i use ifwithoutelse function and WERKS starts with P then multiple idocs are generating perfectly.

WERKS(present in X segment) > StartsWith ('P'constant)-If (Then-X)--> WMMBXY( Target top node).

But if WERKS is not P then nothing is generating at the target side.

Please help !!

Regards,

Suresh.

Former Member
0 Kudos

Change the occurence of IDOC to unbounded by exporting the XSD to local system, changing the occurrence manually & importing as external definition.

And use the logic Avishek suggested.

Regards

Soumen...