cancel
Showing results for 
Search instead for 
Did you mean: 

splitting to multiple files in file adaptor when it's more than 100 records

Former Member
0 Kudos

Hi,

I have a scenario where I'm generating a xml file to the receiver using file adaptor I need to write 100 records per file, if it's more than 100 then I need to write into a different file, to say I need to have 100 records per file.

ABAP Proxy > PI- >File

Any help is really appreciated.

Thanks,

Joe.P

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Joe,

Use a 1 to n mapping to split the message into messages of up to 100 records.

In your message mapping, open the Messages tab and change the occurence of your target message to 0... Unbounded.

Now you use a UDF to split according to number of records.

Eg. context function with parameter 'a':

for (int i=0; i<Math.ceil(a.length/100; i++)

result.addValue(" ");

You would map the records occurence to this function and map this function to the structure below the Message1 structure.

Message was edited by:

Yaghya Nana

Former Member
0 Kudos

Hi Yaghya,

When I test my message mapping I don't see any errors but the output message I don't see any results. this is what I see in the output screen.

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge"><ns0:Message1></ns0:Message1>

</ns0:Messages>

Here I don't see any values and also the subnodes are missing. any ideas what am I doing wrong here.

thanks,

Joe.P

Former Member
0 Kudos

Hi Joe,

What is your source structure and what is your destination structure?

You can go the ABAP proxy route but then your control is not in the integration layer but in the business system. But if you prefer it, here's some code outlined:

data:

index type i,

lcl_proxy type ref to ZCL_Proxy.

i = 0.

try.

loop at lt_recordset into ls_record.

append ls_record to lt_output.

index = index+1.

if index = 100.

create object lcl_proxy.

lcl_proxy->execute_asynchronous(output = lt_output).

index = 0.

clear lt_output.

endif.

end loop.

if index>0.

create object lcl_proxy.

lcl_proxy->execute_asynchronous(output = lt_output).

endif.

catch CX_ROOT.

endtry.

commit-work.

Former Member
0 Kudos

Hi Yaghya

I was able to achieve the split message using the UDF, if I'm using the file adaptor within the communication channel do I have to write some script to write it into multiple files. and if I have to increment the number the file name.

my file name is myfile_01_MMDDYYYY_HHMISS.xml when I'm writing to multiple files I have to increment the number . something like

myfile_01_MMDDYYYY_HHMISS.xml

myfile_02_MMDDYYYY_HHMISS.xml

I really appreciate your help on this.

Thanks,

Joe.P

Answers (5)

Answers (5)

Former Member
0 Kudos

Joe,

You can solve this problem by changing your Interface mapping from 0..Unbounded. Then in Integration Directory change your interface determination to Enhanced mode then select your Interface mapping.

I hope this will resolve your problem.

Regards,

Shridhar Pobbala

Former Member
0 Kudos

Shridhar,

Thanks that solved the problem.

Thanks,

Joe.P

Former Member
0 Kudos

Joe,

You can solve this problem by changing your Interface mapping from 0..Unbounded. Then in Integration Directory change your interface determination to Enhanced mode then select your Interface mapping.

I hope this will resolve your problem.

Regards,

Shridhar Pobbala

Former Member
0 Kudos

when I do end-to-end testing I can't generate the files but I don't see any error in the moni.

Former Member
0 Kudos

Hi Joe,

Check out this thread..on splitting big file into multiple file..

/people/claus.wallacher/blog/2006/06/29/message-splitting-using-the-graphical-mapping-tool

For file name check out this thread..

Hope this will help you.

Nilesh

Message was edited by:

Nilesh Kshirsagar

Former Member
0 Kudos

Hi Joe,

Use Variable substituion for populating the file name dynamically.Refer the below links

/people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i - Dynamic File Name Part 1

/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii - Dynamic File Name Part 2

And refer this thread where the same thing was discussed

Let me know your proceedings..

Cheers

Veera

>>> Reward Points, if it is needful

Former Member
0 Kudos

Hi Veera,

I followed your example, but when I run the message mapping test thru the toll it works fine, but when I do end-to-end test I see empty files generated nothing is written to the files. and I don't see any errors in the moni.

any help would be really appreciated.

Thanks,

Joe.P

Former Member
0 Kudos

Hi Joe,

In ABAP proxy programing you can do this.For Sender Data type set the Occurence 0..Unbounded for the header node.

Suppose u r Data type to be look like

DT_File

Recordset 0..1

Records 0..Unbounded

-


Fields

When you are populating the data through strucutres which are genrated while proxy generation, before calling the Execute Asynchronous method put loop on the structure and assign variable to count. with in the loop you can check that variable equals 100 or not by putting IF conditon and if the records are less than 100 and no morerecords are there -- write the logic for this.With in If condition call your proxy and clear that variable which is used for counting the records.

So that you can able to populate the files for each 100 records. I have done the same where i need to generate the files based on one field value.

Cheers

Veera

>>> Reward points, if it is needful.

Former Member
0 Kudos

Hi,

Thanks for your response. So you are saying we can split the message in ABAP proxy itself and don't use any UDF in the message mapping. do you have the sample ABAP code for this.

thanks,

Joe.P

nisarkhan_n
Active Contributor
0 Kudos

from the above mention steps in ABAP Proxy you are writing the condition so that 100 records are sent to XI at once....so that each file which is generted has only 100 records in it........

i had this stiuation where i created 2 interfcae

1st interface was noram sap->XI->File (file in append mode) , 2nd interface i was picking this file and in Sender file adter i used to set the limit as 100.....