cancel
Showing results for 
Search instead for 
Did you mean: 

READ Message Header

Former Member
0 Kudos

Hí,

i wrote a java module this is reading the payload and the message header attributes.

Payload is ok. But i cannot read the message header attributes. I read the whole sap helping sites but i am still not finished and without any ideas.

I only need the messageID and some other attributes.

I am using Java 1.4 and NWDS 7.0.10

i am already tried to build something like this:

java.util.Map param2 = container.getTransformationParameters();
 String MSGID = (String) param2.get (StreamTransformationConstants.MESSAGE_ID);
 return MSGID;

...but what is about container i didnt get it. Maybe there are other solutions.

Hope i get a src code because i think i read all kinds of websites about these topic.

Sorry i am new in this area and maybe somebody can help me out here.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

container is only used in mappings if you want

to get it form an adapter module:

obj = moduleData.getPrincipalData();

msg = (Message)obj;

msg.getMessageId();

you can the rest in the same way

Regards,

Michal Krawczyk

Former Member
0 Kudos

Thank you for the really fast answer.

But i ve got still a question ..sorry maybe it is stupid but i hope you can help me.

obj = moduleData.getPrincipalData();
msg = (Message)obj;
msg.getMessageId();

Where can i get the "moduleData" ?

I am using :

process(
	ModuleContext moduleContext,
	ModuleData inputModuleData)

inputModuleData is my payload;

And the moduleContext are some special attributes there are set in the SAP view.

Do i have to set the moduleData also in the SAP view ...or how can i get it in my java class?

You see i am a bit lost sorry.

MichalKrawczyk
Active Contributor
0 Kudos

hi,

in your case:

obj = inputModuleData.getPrincipalData();

msg = (Message)obj;

msg.getMessageId();

Regards,

Michal Krawczyk

Former Member
0 Kudos

Oh yes i got i already sorry.

But there are only a few attributes which i can read in there from the Message Header is there one other possibility to read the whole header may with XPath?

Thanks very much

MichalKrawczyk
Active Contributor
0 Kudos

hi,

no, this is not possible

Regards,

Michal Krawczyk

Answers (1)

Answers (1)

former_member200962
Active Contributor
0 Kudos

below piece of code is working for me:

java.util.Map map = container.getTransformationParameters();
String MSGID = (String)map.get(StreamTransformationConstants.MESSAGE_ID);
return MSGID;

I am using it in UDF in message mapping....