cancel
Showing results for 
Search instead for 
Did you mean: 

How to count Number of Input files onTarget Location?

jagesh_lakdawala
Active Participant
0 Kudos

Hi Experts,

I want to identify number of Input files available in Directory of Target system. Input file format is Input*.txt

Once if I have this Count then based on that I can apply further logic in SAP R/3 coding.

Please suggest me for the same.

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

what is your entire scenario to be acheived post more info..

Rajesh

jagesh_lakdawala
Active Participant
0 Kudos

Hi Rajesh,

Thanks for your resposnse.

My requirement is to read the Multiple Input files together and pass these data to R/3 system in a single XML Message.

So I need a Count value in applying LOOP in BPM.

I have used BPM for reading multiple messages and collect it into single XML message.

Regards,

Jagesh

Former Member
0 Kudos

Jagesh,

I guess you can do it without BPM Also,

just change the occurence of yource source message type and in sender file channel put .

And also select a mendatory i/p field and use counter on that...output will give the number of sources files.

Hope this helps you !!!

former_member206760
Active Contributor
0 Kudos

Dear Jagesh,

create a ztable with one field called "count"

you can use a transformation step which will have a mapping and that mapping will be calling a ZRFC(rfc lookup)

now zrfc will have logic of reading the old count from ztable , incrementing the count and returning that count..also updating the incremented count in the ztable...

you can then pass the incrementted count to target datatpe in the mapping...

this would continue for the time that you want the file to get collected say 10 min

after this time dedline is reached ...put another transformation step taht will again set the count field to intital for the next run.

hope this helps

jagesh_lakdawala
Active Participant
0 Kudos

Hi biplab,

Can you explain the same in detiail? because i m new for BPM Concept.

My sceario is Proxy to File. and i want to read multiple input file data in a single XML message and for that purpose i am using the BPM.

purpose of the BPM is to collect input file data one by one through the LOOP and sends single XML message to R/3.

So for running the LOOP in BPM i want this count value.

Regards,

jagesh

Former Member
0 Kudos

Hi, Jagesh:

It seems you just need the count number to control your loop in BPM, is this correct ?

Actually you can also use Block, block have three modes, default, forEach, ParForEach.

You might look for the block of forEach mode, to combine your message, before the block,

you need to have container operator to collect all the files to multi-line elements.

Please refer : /people/milan.thaker/blog/2008/08/05/modes-in-block-step-of-bpm

Regards.

Liang

jagesh_lakdawala
Active Participant
0 Kudos

Hi Liang,

Thanks for your reply.

I have gone through your suggestion but i dont think it will be utilized in my scenario. once agian let me explain my scenaio in detail.

My requirement is to read the Input Text file available on a given Location.Filename format is Input*.txt because Number of Input file is not fixed. All the Input file data needs to be available at the same time in R/3 coding (Internal table). i.e in a single XML message payload.

for that i have configured File sender Adpater and Proxy receiver Adapter.

I have used the BPM delivered by SAP 'BpmPatternCollectPayload' as shown in the below Blog. Sr No 4.

/people/sharathchandra.girmaji/blog/2008/09/11/bpm-with-patterns-explained-part-1

My question is in this BPM how do i know the LOOP Counter?? because LOOP should run depending on the Number of Input files available with the format Input*.txt.

Please suggest.

Regards,

Jagesh

Shabarish_Nair
Active Contributor
0 Kudos

>

> My requirement is to read the Input Text file available on a given Location.Filename format is Input*.txt because Number of Input file is not fixed. All the Input file data needs to be available at the same time in R/3 coding (Internal table). i.e in a single XML message payload.

> My question is in this BPM how do i know the LOOP Counter?? because LOOP should run depending on the Number of Input files available with the format Input*.txt.

>

> Please suggest.

>

> Regards,

> Jagesh

so say at one instance there are 7 files and XI picks them up, your BPM collects it and when you send it to R3 you need to know how many files have been processed?

Well if this is the case, modify your BPM to accommodate collect pattern based on time. So fix a time period basically a time out say an hour. So the BPM will run for an hour after it receives the first file in and if within an hour say 7 files have come in, once the time out kicks in the BPM will exit. In you mapping of N:1 inside the bpm you can write a UDF which will count the occurrance of the root node of the source (a mandatory node of the source) and populate it to any field in the target tht you want to use.

Is this what you are looking for?

jagesh_lakdawala
Active Participant
0 Kudos

Dear Shabarish,

No it is not like that.

I dont want Count in R/3. i need it in LOOP step of the BPM because LOOP should run for each input*.txt file.

for example:- if 6 Input files are available then LOOP step should run for 6 times only.So my question is if 6 Input files are avilable then how do i get value 6 in BPM LOOP step???

once i get this value then 6 XML messages will be collected into a single XML message payload through this BPM and will be sent to R/3.

Regards,

jagesh

Former Member
0 Kudos

Hi,

Have you saw the Pattern no 4: BpmPatternCollectPayload from the blog you had referred.

You need to send the no from sender system to consider the execution of loop for that much time.

Thanks

Swarup

Shabarish_Nair
Active Contributor
0 Kudos

you have to somehow have a variable that should predefine the count or the count should be part of a particular message so that the check can happen

jagesh_lakdawala
Active Participant
0 Kudos

Hi Shabarish,

my question is also same how to get that count???

regards,

jagesh

Shabarish_Nair
Active Contributor
0 Kudos

you can count the number of files that have come in using a counter variable in BPM. A container operation using the parameter assign can increment the number as messages come into XI.

Former Member
0 Kudos

Hi, Jagesh:

If all above suggestions does not fit your situation,

you might think of using "Run operating System Command Before Message Processing"

saying your sending system is windows, you can have VB script to get colletion of the file in the folder,

get the number of file and write to the another file, VB script can be invoked from command line.

For sure you can achive this in unix shell as well.

Then in your BPM, you can using a contianer element to get the number,pass to your loop step.

Regards.

Liang

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

Explain the scenario in details , whether its a file to file scenario.

U r speaking abt the sender side or target side