on 02-27-2012 10:27 AM
Hi,
I have a Proxy to file scenario,where I need to generate "n" number of files if value of a field say "B" is "n".
My source structure is :
Source
A
B
C
Source
How can I do it,all the rest field values will be same in the all the files ,except 1 filed which will increase from 1 to "n" from 1st file to last file.
Regards,
Sri
Edited by: sriparna on Feb 27, 2012 11:28 AM
Edited by: sriparna on Feb 27, 2012 11:28 AM
Edited by: sriparna on Feb 27, 2012 11:29 AM
hi,
I think this can be done by OS commands at target System.
First you copy that file on target System using file adapter.
then by batch file copy that file and update file with value of b.
logic is like below
B=read_file(file1); // this function read value from file1 and return to B
for(i=1;i<=B;i++)
{
copy_file(file1,(filei)); // copy the old file with new name filei
update_file((file+i),i); // update with value of i.
}
Regards
Gagan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The simple solution to your problem is create an UDF and pass the input of field B to udf and return the output as many times as the value of B and map the output of this udf to your target field.
e.g. for(int i = 0; i< B ; i++)
return "";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Duplicating traget structure will not work in your case ,as Sourab suggected use 1.n multi mapping and have to write logic to repeat target structure depending on,but it is bit tricky.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Sriparna
Following is your problem description
You need to create as many files as the number of times the field "B" comes in the source structure
You can create a multimapping (1:n)
Sourabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Sriparna
Make one thing clear
is it like the number of time field B appears in the source structure, you have to create same number of files
or
It is the value inside the Field B (1,2.....n) that many times you have to create the target file
Option 1 is easy one and you do not need a complex logic for that.
Option 2 you can use the node fucntion Use One As Many, where you pass the value of B to that input whch accepts the number of times a node is required to be repeated.
Let me know if I got your requirement correctly
Sourabh
Hi Sourabh,
Thanks for the reply and help..My case is the second one.
If I use 'use one as many' ...then the value of B wil be same in all the nodes on target side,but I want it to work like below:
if say B=2,
then I need 2 files,
one with all values as in source,and value of B=1
second file with all values as in source,and value of B=2...
As I am using a file adapter,I need these two different files based on B's value...It will change to 3 files,if B's value is 3......
Regards,
Sriparna
Dear Sriparna
In that case create a UDF where you take the input as B
Run a for loop (for i=0;i<=(Value of)B:i++)
{
here create source node of file (something like ouput1.addValue(" ") )
and pass the value of B<i> to the next output which is mapped with the target structure's B
}
Let me know if creating this UDF is solving your problem
Sourabh
Hi Sourabh,
I am sorry ,but didnt get this point:
{
here create source node of file (something like ouput1.addValue(" ") )
and pass the value of B to the next output which is mapped with the target structure's B
}
can u explain it a bit clearly,...better in a graphical step by step way..if u can ..please!
Dear Sriparna
First step is to create a UDF (user defined function). Create One input and create two output varaibles for this UDF.
It will have two objectives
1. to create source node of the target message (output1_
2. to create the node B for the target side
As per your requirement you need to create the Source Node of the target message as per the value of B ( if 2 then two source nodes at target)
In the UDF take B as input
int b = B[0];
for(int i=0;i<b;i++)
{
output1.addValue(" "); //you need to map this out put with the source node of your target
output2.addValue(i+1); // this field should be mappoed with the field B of target
}
Hope this clears your confusion
@ gagan: for a requirement like this handling the logic in mapping is the right way to do, I dont think we should go for OS commands
Hi Sourabh,
I have done it,but issue is on sender side I have an idoc.....delvry05....and if I change occurence of sender MT,the source structure also changing with two more node Messages,and Messages1.....
In case of Idoc,how will I get input in such struc from SAP??
and also delvry05 has occurence1...so how do I map a filed B in it to MT,which has become 1 to unbounded,...I tries using "use 1 as many",..but it ddnt work...........
Dear Sriparna
You dont have to worry about the change of structure which you see in your source side, it is just an interpretation in the mapping and will not impact the idoc Delivery05.
You dont have to change the occurence of Sender MT.
Only in operation mapping you need to modify the occurence of target. Please have a llok at the multi mapping done in link below
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3115
I think you were using the UDF instead of one-as-many function, as this node function will not solve your purpose.
Sourabh
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.