cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a Parent Message Id in Mapping?

Former Member
0 Kudos

Hi,

I have a scenario to post the idoc to file to mulitple receivers. I have to get both Message ID and Parent Message ID in mapping. I am able to get Message ID but not Parent Message ID. I tried to get it from Table sxmspmast but it does not contain the entry during runtime.

Any suggestions to get the Parent ID while in Mapping.

Thanks,

Manikandan R

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

maybe a dummy mapping of IDoc to single File in which you can extract the message id (parent) followed by 1 File to N file mapping in which you can get the child message id?

former_member206760
Active Contributor
0 Kudos

u can use the ABAP mapping..

IF_IXML_DOCUMENT has methods IF_IXML_NODEGET_GID and IF_IXML_NODEGET_PARENT

get the parent first and then its GID

Former Member
0 Kudos

Hi Tarang,

I think the GET PARENT that you have mentioned will get the PARENT Node not the PARENT ID.

Regards,

Manikandan R

former_member206760
Active Contributor
0 Kudos

yes it will get u the parent node...after u get parent node...u can get its GID using the second method mentioned by me

shweta_walaskar2
Contributor
0 Kudos

you can create a UDF,say getMSGID, to get current message ID:

String headerField;

java.util.Map map;

// get runtime constant map

AbstractTrace trace=container.getTrace();

map = container.getTransformationParameters();

String key = "MessageId";

// get value of header field by using variable key

headerField = (String) map.get(key);

return headerField;

pass this output to an RFC lookup UDF which calls this FM in XI ABAP stack:

FUNCTION ZGET_PARENT_MSG_ID.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(I_CURRMSGID) TYPE CHAR40

*" EXPORTING

*" VALUE(E_PARENTMSGID) TYPE CHAR40

*"----


DATA: lv_currmsgid type SXMSPMAST-MSGGUID,

lv_parentmsgid LIKE SXMSPMAST-PARENTMSG,

lv_currmsgid = i_currmsgid.

select single PARENTMSG from SXMSPMAST into lv_parentmsgid where MSGGUID = lv_currmsgid.

e_premsgid = lv_parentmsgid.

ENDFUNCTION.

Former Member
0 Kudos

Hi Shweta,

I treid the same step already querying the same table using lookup. But during mapping the current message id record is not available in the specified table. Have you been successful?

Regards,

Manikandan R

shweta_walaskar2
Contributor
0 Kudos

Hello Manikandan,

We had a requirement where we create an IDoc out of EDIFACT file and then create an APERAK (Application Error acknowledgement) having the contents from original file along with the status of IDoc posted.

So I had created two mappings :

1) EDIFACT - IDoc

2) EDIFACT - APERAK

I needed to have IDoc status posted by first mapping and hence,I needed a reference to previous mapping in my current mapping.

In this case,I had a parent message with two child messages created for these two mappings.

So I had to pass current message ID and get parent message ID and then this parent message ID was used to get another child which would be the message created by first mapping.

Hence,in addition to the code I mentioned,I had an additional database query where I pass parent message ID in the same table to get another child message ID.

But it worked fine and this scenario has been live for a long time.

I believe,it should work in your case also.

Else,please let me know what exactly you are trying to achieve and where is it failing.

Regards,

Shweta

Former Member
0 Kudos

Hi Shweta,

An Outboud Idoc has to be posted as file to three different locations with the same file name.

File Name is generated in RFC lookup. I am using mulitple receivers in RD. I am using same interface mapping in all the ID.

When the MM gets exectued, in lookup, I will query the SXMS*MAST table for parent message id, this parentmsg id is used to get the filename from the customized table, if the entry is there it will return filename, else it will create the entry and retun filename.

When i tested, the *MAST table does not give parentmsgid as the entry is not yet recorded at that time.

It is available for you because you are querying in the second mapping, so u will be having the entry.

Now we are handling our logic using IDOC Number.

Thanks Shwetha..

Regards,

Manikandan R

Answers (1)

Answers (1)

Former Member
0 Kudos

Instead of MsgId, Idoc Number is persisted and File Name is returned based on it.

shweta_walaskar2
Contributor
0 Kudos

Hi Manikandan,

Yes,you are right.

I understood it now,thanks for the explanation.

Regards,

shweta