cancel
Showing results for 
Search instead for 
Did you mean: 

defining mapping program

Former Member
0 Kudos

hi all.

here iam dealing with file to BAPI.

mw sender sample file is

in sender file.

HEADER|22012007|WMD

123565139|220.05

133565127|1230.05

143565511|260.00

153565812|11345.05

122565912|320.05

123565013|21259

125565814|232.05

131565212|200.00

132565145|38.05

134565173|5213.10

136565191|298.05

137565132|228.10

TRAILER|12|40843.55

for this i have created my data type as

header

under header my datatypes are

docdate

siteid.

nad under body

accno

amount

and under footer

totrec

toamt

here when iam mapping with BAPI.

and while iam testing iamgetting docdate and siteid only for first record and for remaining records it remains blank,

but

i should get the doddate,siteid for all the records in bapi.

waiting for the great answer.

bye.

regards.

seeta ram.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Seeta Ram,

you can achive this using node funtion "UseOneAsMany".

you have 3 inputs reqd..

1) the header field to be mapped

2) the line item node

3) any line line item under this node.

and map this to target header field.

Regards

Pushkar

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Seeta,

why dont you try UseOneAsMany Node function.

That is the simplest way as suggested in my first very reply..

Its a pretty common problem and hence SAP has provided a function for this.

you dont get into complexities of defining new UDFs.

Try to use that as suggested and if you have ne problem, please let me know.

Regards

Pushkar

former_member214364
Active Contributor
0 Kudos

> hi all.

> for this i have created my data type as

>

><b> header</b>

> under header my datatypes are

> docdate

> siteid.

>

> nad under <b>body</b>

> accno

> amount

> and under footer

> totrec

> toamt

Hi Seeta Ram,

if you do the mapping in the following way without UDFs it works

1. <b>docdate</b> from source map to <b>docdate</b> in target as follows

a. take <b>docdate</b> from target structure and <b>useOneAsMany</b> node function

b. the three input fields for <b>useOneAsMany</b> function are

b.1. parameter-1:<b>docdate</b> from source message

b.2. parameter-2:<b>body</b> node from source structure and change <b>context</b> to <b>header</b>'s node parent,you can do this just by right click on body node

b.3. parameter-3:just<b> body</b> node without any context change as in b.2 step

2. <b>siteid</b> from source map to <b>siteid</b> in target as follows

a. take <b>siteid</b> from target structure and <b>useOneAsMany</b> node function

b. the three input parameters for <b>useOneAsMany</b> function are

b.1.parameter-1: <b>siteid</b> from source message

b.2.parameter-2: <b>body</b> node from source structure and change <b>context</b> to <b>header</b>'s node parent,you can do this just by right click on siteid node

b.3.parameter-3: just <b>body</b> node without any context change as in b.2 step

if there is any issue please let us know

Cheers,

Jag

Former Member
0 Kudos

hi jag thanks for u r help.

but.

here when i do the mapping test it doesnt work.

and i got one doubt in mapping

once again here my sender structure is

mt_optotoisu

accdetails

header

doddate

siteid

body

accno

amount

trailer

totrec

totamt

but u said that change the context of body to header

but when i rightclick on that its displaying only 2 options

one is accdetails

2nd is mt_optotoisu.

so there is confuse to which i have to set context.

waiting for u r response.

bye.

regards.

seeta ram

justin_santhanam
Active Contributor
0 Kudos

Seeta,

I couldn't understand what happens if we add three lines of code, will make big complexity in the program. Of course we do have some standard functions, choose whichever is comfortable for u.

Source structure.

MT_Input

<b>Header 1..1</b>

docdate 1..1

siteid 1..1

<b> Body 1..unbounded</b>

accno 1..1

amount 1..1

<b> Footer 1..1</b>

Totrec 1..1

Totamt 1..1

MT_Output

<b>yisu_bapi 0..1</b>

<b> e_waste 0..1</b>

<b> item 0..unbounded</b>

docdate 0..1

siteid 0..1

amount 0..1

accno 0..1

totrec 0..1

Note : Bolded letters are node with same level.

UDF : Create advanced UDF with Queue[option select] with two inputs.

For example lets say input variable name is input1 and input2

<u><b>Code</b></u>

int cnt = input2.length;

for(int i=0;i<cnt;i++)

{

result.addValue(""input1[0]"");

}

Mapping logic.

Don't Map -


> <b>MT_Output</b>

Constant -


><b>yisu_bapi</b> [bcoz u didn't mentioned what is the source for this node]

Constant----


><b>e_waste</b> [bcoz u didn't mentioned what is the source for this node]

Body -


> <b>item</b>

docdate[input1] & accno[input2][change context to MT_Input] -


> UDF -


> Splitbyvalue[EachValue]----><b>docdate</b>

siteid[input1] & accno[input2][change context to MT_Input] -


> UDF -


> Splitbyvalue[EachValue]----><b>siteid</b>

amount -


><b>amount</b>

accno -


><b>accno</b>

Totrec[input1] & accno[input2][change context to MT_Input] -


> UDF -


> Splitbyvalue[EachValue]----><b>totrec</b>

Note : No need to import anything.

I hope it helps you!!!!

Best regards,

raj.

Former Member
0 Kudos

hi jag.

thanks for your help.

but i raised one more question on the same topic to u.

iam waiting for u r answer.

but no reply from u.

waiting for u.

bye.

regards.

seeta ram.

Former Member
0 Kudos

hi jag thanks for u r help.

but.

here when i do the mapping test it doesnt work.

and i got one doubt in mapping

once again here my sender structure is

mt_optotoisu

accdetails

header

doddate

siteid

body

accno

amount

trailer

totrec

totamt

but u said that change the context of body to header

but when i rightclick on that its displaying only 2 options

one is accdetails

2nd is mt_optotoisu.

so there is confuse to which i have to set context.

waiting for u r response.

bye.

regards.

seeta ram

justin_santhanam
Active Contributor
0 Kudos

Friends,

I think Ram, is not satisfied with the UDF which I wrote above, can u guys suggest how to use <b>UseOneasMany</b> for the structure. So he can proceed further.

I haven't worked on that function.:-)

Best regards,

raj.

justin_santhanam
Active Contributor
0 Kudos

Ram,

I got it finally..

Please use the same mapping logic in my above replies. For the places where I used UDF , change the following.

Mapping logic.

Don't Map -


> MT_Output

Constant -


>yisu_bapi [bcoz u didn't mentioned what is the source for this node]

Constant----


>e_waste [bcoz u didn't mentioned what is the source for this node]

Body -


> item

docdate[<b>param1</b>],accno[Change context to MT_Input -<b>param2</b>], accno[Dont change context-<b>param3</b>]----><b>useoneasmany</b> ->Splitbyvalue[EachValue]-->docdate

siteid[<b>param1</b>],accno[Change context to MT_Input -<b>param2</b>], accno[Dont change context-<b>param3</b>] -


><b>useoneasmany</b> ->Splitbyvalue[EachValue]-->siteid

amount -


>amount

accno -


>accno

totrec[<b>param1</b>],accno[Change context to MT_Input -<b>param2</b>], accno[Dont change context-<b>param3</b>] -


><b>useoneasmany</b> ->Splitbyvalue[EachValue]-->totrec

Best regards,

raj.

former_member214364
Active Contributor
0 Kudos

Hi Seeta Ram,

sorry for delay in reply.

>but u said that change the context of body to header

>but when i rightclick on that its displaying only 2 options

>one is accdetails

>2nd is mt_optotoisu.

in my last post i said to change the <b>context</b> of <b>body</b> node to <b>Header's parent node</b> not to <b>Header</b> node

you need to select <b>accdetails</b>(right click on <b>body</b> node) if you have the source structure in the following format

-


mt_optotoisu

-


accdetails(its child of mt_optotoisu node)

-


Header(its child of accdetails node)

-


body(its child of accdetails node)

please let me know if you have any queries.

Cheers,

Jag

Former Member
0 Kudos

In Short

HeaderField

LineItemNode [UseOneAsMany] TargetHeaderField

LineItemField

Regards

Pushkar

Message was edited by:

Pushkar Anand

Former Member
0 Kudos

hi pushkar.

thanks for u r answer.

but how we can do that.

can u guid me please.

bye.

regards.

seeta ram.

justin_santhanam
Active Contributor
0 Kudos

Ram,

If you find the above results to be appropriate to ur reqmts. Please follw the below to achieve the same.

For nodes yisu_bapi & e_waste map acc to ur reqmt.

Item(target) map the source body node

Docdate(target) as shown in the jpg. Note change the accno context to higher level.

siteid(target) same as above.

amount and accno map directly from source(node to node mapping)

totrec(target) as shown in the jpg.

<b>UDF logic.</b>

Create UDF(Queue) with two input(input1,input2)

int cnt = input2.length;

for(int i=0;i<cnt;i++)

{

result.addValue(""input1[0]"");

}

I hope it clears.

Best regards,

raj.

Former Member
0 Kudos

thanku puskar.

yes my question heass been well ansered by you.

thankyou very much.

i had done lot of stuff for this but i cont.

thanku very much.

bye.

regards.

seeta ram.

justin_santhanam
Active Contributor
0 Kudos

Ram,

Can u please give the exact source structure with occurrences also target structure with occurrences, it could be easy for us to suggest the soultion.

Best regards,

raj.

Former Member
0 Kudos

hi the occurences r as follows

header 1..1

under header my datatypes are

docdate 1..1

siteid. 1..1

nad under body 1...unbounded

accno 1..1

amount 1..1

and under footer 1..1

totrec 1..1

toamt 1..1

and the structure of bapi is

yisu_bapi 1..1

e_waste 0..1

item 0....unbounded

docdate 0..1

siteid 0..1

amount 0..1

accno 0..1

totrec 0..1

here when iam mapping with BAPI.

and while iam testing iamgetting docdate and siteid only for first record and for remaining records it remains blank,

but

i should get the doddate,siteid for all the records in bapi.

waiting for the great answer.

bye.

regards.

seeta ram.

justin_santhanam
Active Contributor
0 Kudos

Ram,

Please find the structure and the output, I added the jpg in the below URL.

Please confirm me, so that I will guide u to achieve the same.

Structure :

http://www.flickr.com/photos/8764045@N06/565061865/

Results :

http://www.flickr.com/photos/8764045@N06/565061857/

Best regards,

raj.

Former Member
0 Kudos

sorry raj.

thanks for your cooperation but i cont access those due to my company recrictions.

so can u explain me briefly in words please.

waiting for u .

bye.

regards.

seeta ram.

justin_santhanam
Active Contributor
0 Kudos

Ram,

No probes. Please find the below source and target structure I've defined.

Source

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Check_In xmlns:ns0="urn:hdmc:samplescenarios">

<Header>

<docdate>DOC061807</docdate>

<siteid>ID9000</siteid>

</Header>

<Body>

<accno>AC9001</accno>

<amount>10000</amount>

</Body>

<Body>

<accno>AC9002</accno>

<amount>20000</amount>

</Body>

<Footer>

<Totrec>2</Totrec>

<Totamt>30000</Totamt>

</Footer>

</ns0:Check_In>

Target

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Check_Out xmlns:ns0="urn:hdmc:samplescenarios">

<yisu_bapi>Constant</yisu_bapi>

<e_waste>Constant</e_waste>

<item>

<docdate>DOC061807</docdate>

<siteid>ID9000</siteid>

<amount>10000</amount>

<accno>AC9001</accno>

<totrec>2</totrec>

</item>

<item>

<docdate>DOC061807</docdate>

<siteid>ID9000</siteid>

<amount>20000</amount>

<accno>AC9002</accno>

<totrec>2</totrec>

</item>

</ns0:Check_Out>

Based on this structure I've defined the mapping.

As I said in the previous reply follow the same steps.

For target DocDate,SiteID and totrec.

In the UDF pass Input 1 as DocDate and Input 2 as accno(Change the context)

output of UDF -->Splitbyvalue[eachvalue] -->docdate

In the UDF pass Input 1 as siteid and Input 2 as accno(Change the context)

output of UDF -->Splitbyvalue[eachvalue] -->siteid

In the UDF pass Input 1 as totrec and Input 2 as accno(Change the context)

output of UDF -->Splitbyvalue[eachvalue] -->totrec

Best regards,

raj

justin_santhanam
Active Contributor
0 Kudos

Ram,

Does the logic works for you?

best regards,

raj.

Former Member
0 Kudos

hi raj thanks for u r help but when i tried for udf.

and when i tested i got errors like

10:15:28 Start of test

Source code has syntax error: /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3f7fa3001e3d11dcc04b00144f2b5900/source/com/sap/xi/tf/_MM_OPTOAFRICAtoSAPISU_.java:3: '.' expected import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import siteid;import accno; ^ /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3f7fa3001e3d11dcc04b00144f2b5900/source/com/sap/xi/tf/_MM_OPTOAFRICAtoSAPISU_.java:3: '.' expected import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import siteid;import accno; ^ /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3f7fa3001e3d11dcc04b00144f2b5900/source/com/sap/xi/tf/_MM_OPTOAFRICAtoSAPISU_.java:166: illegal start of expression import java.io.; ^ 3 errors Source code has syntax error: /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3f7fa3001e3d11dcc04b00144f2b5900/source/com/sap/xi/tf/_MM_OPTOAFRICAtoSAPISU_.java:3: '.' expected import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import siteid;import accno; ^ /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3f7fa3001e3d11dcc04b00144f2b5900/source/com/sap/xi/tf/_MM_OPTOAFRICAtoSAPISU_.java:3: '.' expected import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import siteid;import accno; ^ /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3f7fa3001e3d11dcc04b00144f2b5900/source/com/sap/xi/tf/_MM_OPTOAFRICAtoSAPISU_.java:166: illegal start of expression import java.io.; ^ 3 errors

10:15:35 End of test

is there any need to import the packages.

if so.

can u write what r the packages we have to import.

waiting for u.

bye.

regards.

seeta ram.