cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help with Message Mapping in PI 7.1 - JDBC to IDOC

Former Member
0 Kudos

I have an outgoing SQL function that sends multiple rows of data for use in creating an IDOC in ECC. I am trying to key the creation of new IDOCs (already did the maxOccurs trick to the IDOC definition) based on a field in the JDBC return data...

JDBC Message Format...

SEGNAM - TRANS_ID - MATERIAL - VKORG...ETC

MARA - 00001 - 1234 - <space> - ...

MARC - 00001 - 1234 - VK01 - ...

MARA - 00002 - 9876 - <space> - ...

MAKT - 00002 - 9876 - <space> - material description - ...

Each time there is a new TRANS_ID, I need to indicate a new IDOC in the message mapping. I have tried all kinds of combinations of TRANS_ID --> dropContext --> splitValue and TRANS_ID --> collapseContext --> splitValue, but nothing has worked.

Has anyone done this kind of message map (without any BPM please)?

Thanks,

Nathan

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Please use following logic:

TRANS_ID --> removeContext --> sort:ascending --> splitByValue:ValueChanged --> collapseContext --> IDOC

this would create one IDOC for every Trans_ID.

And for the other fields in every record, please use sortByKey and FormatByExample to group the records for every IDOC.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Nathan,

I have tried all kinds of combinations of TRANS_ID --> dropContext --> splitValue and TRANS_ID --> collapseContext --> splitValue, but nothing has worked.

Remember that you have placed a splitByValue just after you have removed the context of TRANS_ID. This would cause the mapping to only take the first value of the context. The right way would be


TRANS_ID --> removeContext --> sort:ascending --> splitByValue:ValueChanged --> collapseContext --> IDOC

The code above would ensure that there are no duplicate TRANS_ID whenever you are creating a new IDOC.

Hope this helps,

Mark

Former Member
0 Kudos

Mark,

Can I ask a follow up?

Your solution worked well, so that each unique TRANS_ID now creates one IDOC regardless of how many rows (other segments) are contained in the incoming data.

My question is, how do I now address each row for further mapping, i.e.

row 1 SEGNAM = MARA, TRANS_ID = 1, MATNR = 123...

row 2 SEGNAM = MARC, TRANS_ID = 1, MATNR = 123, WERKS = PL01...

row 3 SEGNAM = MARA, TRANS_ID = 2, MATNR = 987

Right now, if there are 2 TRANS_IDs in the incoming data, I get two IDOCs, but only access to the first 2 rows of data for mapping...even if there are other rows that should be part of the two IDOCs (e.g. other segments).

Thanks,

Nathan

stefan_grube
Active Contributor
0 Kudos

segnam -


v

Trans_ID>removeContect>SplitbyValue-->formatByExample - equalS(MARA) - createif - MARA

.....................................................................................................- equalS(MARC) - createif - MARC

and so on

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Nathan,

For this one, you have to play with contexts.

row 1 SEGNAM = MARA, TRANS_ID = 1, MATNR = 123...

row 2 SEGNAM = MARC, TRANS_ID = 1, MATNR = 123, WERKS = PL01...

row 3 SEGNAM = MARA, TRANS_ID = 2, MATNR = 987

This also depends on the occurrence of the parent node. example, if I want MATNR to be populated, the logic would be like

ex:

IDOC1..unbounded) (The logic is the already provided in an earlier response)

-->MATNR (1..1)


MATNR --------> removeContext ----------------> FormatByExample --> MATNR
TRANS_ID --> removeContext --> splitByValue:ValueChange --> /

If the rows are not in order of trans_id, then you need to incorporate sorting into the logic above.

Hope this helps,

Mark

Former Member
0 Kudos

Stefan,

Thanks for the help. I am following you suggestion and getting the segments to appear.

The top-level segment, MARA, is working perfectly. The problem is that the sub-segments, e.g. MARC, only appear in one of the two IDOCs/TRANS_ID in my sample file. How can I make sure that the sub-segments (MARC, MARD, etc) are processed for each TRANS_ID and appear in their respective IDOCs?

Thanks,

Nathan

Sample data (subset of columns, but with example keys of segnam, trans_id, and matnr):

MARA,1,TestPart1,ZASM,MFG,EA,10.000

MARC,1,TestPart1,NULL,NULL,NULL,NULL

MARD,1,TestPart1,NULL,NULL,NULL,NULL

MARD,1,TestPart1,NULL,NULL,NULL,NULL

MLAN,1,TestPart1,NULL,NULL,NULL,NULL

MTXL,1,TestPart1,NULL,NULL,NULL,NULL

MARA,2,TESTPART2,ZCOM,MFG,EA,1.000

MARC,2,TESTPART2,NULL,NULL,NULL,NULL

MARC,2,TESTPART2,NULL,NULL,NULL,NULL

MARD,2,TESTPART2,NULL,NULL,NULL,NULL

MARD,2,TESTPART2,NULL,NULL,NULL,NULL

MLAN,2,TESTPART2,NULL,NULL,NULL,NULL

MTXL,2,TESTPART2,NULL,NULL,NULL,NULL

Edited by: Nathan Leach on Dec 16, 2010 3:26 PM

stefan_grube
Active Contributor
0 Kudos

I think you need a splitbyvalue between createif and the target. (MARC, MARD)

Your mapping will be really complex. You have to play a little of the node function to get it aligned.

This is not easy.

Former Member
0 Kudos

Grasping at straws now...would swapping the SEGNAM and TRANS_ID field order help?

TRANS_ID, SEGNAM, MATNR, ...

1, MARA, MAT1...

1, MARC, MAT1...

2. MARA, MAT2...

2, MARC, MAT2...

I guess I don't really understand the process...I am used to much simpler mappings. Anything more info you can provide would be greatly appreciated.

Thanks,

Nathan

stefan_grube
Active Contributor
0 Kudos

check this blog for the use of formatbyexample:

/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13

check this blog for the use of ifwithoutelse and createif

/people/stefan.grube/blog/2006/01/09/the-use-of-suppress-in-the-xi-30-graphical-mapping-tool

You have to make sure, that the context of the targets are aligned.

The node functions splitbyvalue and removecontexts will help you.

RKothari
Contributor
0 Kudos

Hi,

Have you tried the below logic:

Trans_ID>removeContect>SplitbyValue(Value change)>collapseContext>Idoc (0..unbounded)

-Rahul

former_member214364
Active Contributor
0 Kudos

Hi Nathan,

What are the occurrences of the following fileds and their hierarchy

SEGNAM

TRANS_ID

Have to tried with removeContexts node function?

Cheers,

Jag