hello Folks,
I am new to ABAP development. Kindly excuse me if this question is already asked.
I have written the following code for creating file at AL11.
I have given file name as /usr/sap/trans/ecc/tmp/poonam.txt
I can see directory path till /usr/sap/trans/ecc/tmp
However then also my open dataset statement is failing.
my doubt is do i need to create a blank file at this location before executing the program ?
if not kindly assist me how to solve this issue.
REPORT YPM_AL11_1.
TYPES : BEGIN OF st_DEMO,
EMP_NO(5) TYPE C,
NAME(20) TYPE C,
ADDR(30) TYPE C,
END OF ST_DEMO.
DATA : WA_DEMO TYPE ST_DEMO,
IT_DEMO TYPE TABLE OF ST_DEMO,
L_FNAME TYPE STRING .
PARAMETERS: P_FNAME(128) TYPE C DEFAULT '/usr/sap/trans/ecc/tmp/poonam.txt' OBLIGATORY.
L_FNAME = P_FNAME.
WA_DEMO-emp_NO = '51117'.
WA_DEMO-NAME = 'Poonam'.
WA_DEMO-ADDR = 'Bangalore'.
APPEND WA_DEMO TO IT_DEMO.
WA_DEMO-EMP_NO = '11111'.
WA_DEMO-NAME = 'HARSH'.
WA_DEMO-ADDR = 'Mumbai'.
APPEND WA_DEMO TO IT_DEMO.
OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
WRITE :5 'EMP NUM',16 'NAME',37 'ADDRESS' . " Header of file to be created in specified location
LOOP AT IT_DEMO INTO WA_DEMO.
IF SY-SUBRC = 0.
TRANSFER WA_DEMO TO L_FNAME.
WRITE :/5 WA_DEMO-EMP_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.
ENDIF.
ENDLOOP.
close dataset l_fname.