cancel
Showing results for 
Search instead for 
Did you mean: 

Abap mapping and variable substitution in File adapter

Former Member
0 Kudos

Hi experts!!.

I am new in abap mapping, but I can do one abap mapping succesfully, but my problem is:

I need to do a variable substitution in my file receiver adapter:

Target directory = %cliente&/out

File Name Scheme = TC%Fecha%.EFI

¿Using abap mapping is this possible? How I can do it?.

Please is very urgent.

Thanks in advance, and best regarts.

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

If the target filename and directory are going to be in the target message then it does not matter what filename and direcytory you use.

You can use the variable nakme substitution.

payload: and the path of the payload where the varibale will contain value.

SAP help describes it pretty well,

http://help.sap.com/saphelp_nw2004s/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

Regards

bhavesh

Former Member
0 Kudos

Hello Bhavesh!

Your answer is perfect, but my problem is that value of "Cliente" and "Fecha" are both inside input file message.

If i use a normal message mapping problem solved, but for n reasons, i don´t do it, and then appears

Abap Mapping

, i do all steps but if I want mount file name using variable substitution, but how i can do it?

Can you help me?

bhavesh_kantilal
Active Contributor
0 Kudos

hmm..So are these fields not a part of the output file then?

if yes, then there is another solution. Do not use Variable Substitution. Use Adapter Specific Identifiers and In your interface mapping have 2 mappings.

1.The first will be a graphical mapping that will use the same source and target message type ( ie. the source will be the target message also) . This will be a straight mapping and you can have the FileName set dynamically using the Adapter Specific Identifiers.

2. The next mapping will be you ABAP mapping and this will do the mapping functionality for you.

Wouldnt this do the trick?

Regards

Bhavesh

Former Member
0 Kudos

umm... not this fields are in Source file, but i don´t need in target file..so, i used an Abap Mapping. I need these fields only to create a Target file name into file adapter...

Is so difficult?¿ Perhaps i need to do an Abap mapping that the result are a XML message with the same structure that MT_OUPUT (message type output), and then I can use a variable substitution..... but i don´t know...

Sorry, if i don´t explain well...

Thanks in advance..

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

The solution I have exmplain is pretty simple.

You are just introducing a dummy graphical mapping that will set the filename inside a UDF dynamically ( 3 lines of code ). And then you are calling your ABAP mapping as per requirement.

Let me know if you have not got the exact flow yet.

regards

Bhavesh

Former Member
0 Kudos

Do you have ans example of this UDF?

Thanks..

bhavesh_kantilal
Active Contributor
0 Kudos

Sure do have it .

It is on sap help itself.

Look at the code in this link, its as simple as that.

http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm

Regards

Bhavesh

Former Member
0 Kudos

ok perfect!

I can change using the same method Target directory ?

Thanks!

bhavesh_kantilal
Active Contributor
0 Kudos

Yes you can,.

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

will become

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“Directory”);

In the receive file adapter all you would need to do is select Adapter Specifc Attributes --> File Name and Directory and givce some dummy values for the filename and directroy. In the runtime values will be taken from the SOAP header which you set in the mapping.

Regards

Bhavesh

Answers (1)

Answers (1)

henrique_pinto
Active Contributor
0 Kudos

Hey there,

For ABAP Mapping, check out IF_MAPPING_DYNAMIC_CONFIGURATION interface.

As posted by Michal in some post, your abap mapping would be something like:

METHOD if_mapping~execute.

DATA l_record type mpp_dynamic.

* copy payload
result = source.

* add an adapter specific attribute
l_record-namespace = 'http://sap.com/xi/XI/System/File'.
l_record-name = 'FileName'.
l_record-value = 'test.xml'.
dynamic_configuration->add_record( l_record ).

ENDMETHOD.

Regards,

Henrique.

Former Member
0 Kudos

Hello Henrique!

Thanks for all...

Very best answer!!!!! My problem is totaly solved!! I only put this code in Abap Mapping and i can change all properties of my File adapter...

Thanks!!!.. Great answer!

henrique_pinto
Active Contributor
0 Kudos

Hi Julián,

glad it helped.

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Henrique,

Great info

Regards

Bhavesh

Former Member
0 Kudos

Hello Henrique!

Please can you help me?

I need to do two message mapping un my Idoc->Flat file scenario. One normal "message mapping" and the other and abap mapping.

The question is, in abap mapping i can put in result variable, XML source variable?

The abap mapping I only need to search a field in a R/3 table, and chage Filaname, and Directory, and then I need put to the Result variable , Input source variable

Its possible?

Thanks best Regards.

bhavesh_kantilal
Active Contributor
0 Kudos

Julian,

I did not follow the entire requirement, but if i got you correct you need to add 2 mappings in the interface mapping.

One a Graphical mapping and this followed by the abap mapping.

The basic point when you have 2 mapping programs in the interafce mapping is that the source message is the input to the 1st mappping and the output of this is the input to the second mapping and the output of the second mapping is the final output of the interface mapping.

Regards

Bhavesh

henrique_pinto
Active Contributor
0 Kudos

Hey Julian,

check out the sample code I gave. It already copies the payload from input into output.

* copy payload
result = source.

But see, are you using ABAP mapping for dynamic configuration just because you need to read some value from RFC?

I'm not sure about your scenario, but since you already have message mapping, maybe it'd be much better if you did dynamic configuration in message mapping itself, and to get the necessary field, you could use RFC Lookup. It'd have a much better performance.

Regards,

Henrique.