Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

File writing onto Application Server

Former Member
0 Likes
1,142

Hi,

I am able to store the Invoice onto the Application Server but when we try to store 2 or more invoices , on the application server the file gets overwritten with both the invoices .

I want to store only one invoice for each Invoice when the transaction is executed.

This is my Code .

CONCATENATE '/usr/xxx/' '<' NAST-PARNR '>'

'<' NAST-OBJKY '>' INTO LV_FILE1.

OPEN DATASET LV_FILE1 FOR OUTPUT IN BINARY MODE.

IF SY-SUBRC EQ 0.

LOOP AT OUT_TAB.

TRANSFER OUT_TAB TO LV_FILE1.

ENDLOOP.

CLOSE DATASET LV_FILE.

ENDIF.

Can anybody please tell me what might be the problem.

with rgds

Ranjith Singh

Hi,

I am able to store the Invoice onto the Application Server but when we try to store 2 or more invoices , on the application server the file gets overwritten with both the invoices .

I want to store only one invoice for each Invoice when the transaction is executed.

This is my Code .

CONCATENATE '/usr/xxx/' '<' NAST-PARNR '>'

'<' NAST-OBJKY '>' INTO LV_FILE1.

OPEN DATASET LV_FILE1 FOR OUTPUT IN BINARY MODE.

IF SY-SUBRC EQ 0.

LOOP AT OUT_TAB.

TRANSFER OUT_TAB TO LV_FILE1.

ENDLOOP.

CLOSE DATASET LV_FILE.

ENDIF.

Can anybody please tell me what might be the problem.

with rgds

Ranjith Singh

9 REPLIES 9
Read only

Former Member
0 Likes
1,100

Hi,

Create a unique file name, use the invoice number in the filename, if you want one file to be created per invoice.


CONCATENATE '/usr/xxx/' '<'>'
'<'>'  vbrk-vbeln INTO LV_FILE1.  "vbrk-vbeln or the corresponding variable in your code

Regards,

Chen

Read only

Former Member
0 Likes
1,100

Hi ,

Thanx for the reply but both the invoices are different.

with rgds

Ranjith Singh

Read only

Former Member
0 Likes
1,100

Hi,

if you want to save all invoices into a single file you have to open this file FOR APPENDING instead of FOR OUTPUT.

Regards,

Klaus

Read only

Former Member
0 Likes
1,100

HI Klaus,

I want to store each invoice separately , but where as when 2 invoices are printed i see that the both file which were updated earlier also gets updated and it will be over written with the current invoices.

rgds

Ranjith Singh

Read only

0 Likes
1,100

Hi Ranjith,

to make sure that the file is not overwritten by the 2nd invoice you need different file names including e.g. with VBELN (as Chen described above) or an ascending number.

You didn't tell us the following process on the file (transfer or whatever). But you need one single file for each invoice in a program run. They may ever start with number 1 to n for n invoices, if the following process has worked (and removed) the files.

Regards,

Klaus

Read only

0 Likes
1,100

Ranjit,

Use the invoice along with DateTime stamp or use a Z number range to get a unique number for every save of the invoice.

Also, check with the target system which consumes this file to get to a consensus on the filename pattern.

Regards,

Chen

Read only

Former Member
0 Likes
1,100

I Created a new Number range and concatenated . Thanx Chen and Klaus

Read only

yuri_ziryukin
Product and Topic Expert
Product and Topic Expert
0 Likes
1,100

Hello Ranjith,

By the way, you are opening dataset with name LV_FILE1, writing to it, but you close the dataset with another name LV_FILE.

I guess this is not correct

Cheers,

Yuri

Read only

Former Member
0 Likes
1,100

Hi Yuri,

that was a typo error.