‎2011 Sep 15 7:48 PM
hi,
I have the below program, some how i need to get this data in table to application server as file under /usr/sap/tmp directory of AL11 transaction code.
Can you advice what could be wrong in this, why is it not loading the file. there are no errors but i cannot see any file uploaded in AL11.
TYPES : BEGIN OF ST_DEMO,
REG_NO(10) TYPE C,
NAME(20) TYPE C,
ADDR(20) 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\tmp\down.txt' OBLIGATORY.
L_FNAME = P_FNAME.
WA_DEMO-REG_NO = '100001'.
WA_DEMO-NAME = 'ANAND'.
WA_DEMO-ADDR = 'NAGARKOVIL'.
APPEND WA_DEMO TO IT_DEMO.
WA_DEMO-REG_NO = '100002'.
WA_DEMO-NAME = 'VIKRAM'.
WA_DEMO-ADDR = 'CHENNAI'.
APPEND WA_DEMO TO IT_DEMO.
OPEN DATASET P_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .
LOOP AT IT_DEMO INTO WA_DEMO.
IF SY-SUBRC = 0.
TRANSFER WA_DEMO TO P_FNAME.
WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.
ENDIF.
ENDLOOP.
Edited by: MercAMG on Sep 15, 2011 7:49 PM
‎2011 Sep 15 8:33 PM
‎2011 Sep 15 7:52 PM
Well, you aren't testing sy-subrc after you open the file, so you don't know if that worked.
Then you do test sy-subrc within the loop. There is no reason to do that.
Rob
‎2011 Sep 15 7:54 PM
Hi
Please check whether you have authorization create modify files in Application Server. Try uploading T Code CG3Z and check whether the file is successfully uploaded or not.
You need to check SY-SUBRC after OPEN File
[Please see|http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3cc0358411d1829f0000e829fbfe/content.htm]
Shiva
‎2011 Sep 15 8:29 PM
this is what i changed to:
OPEN DATASET P_FNAME FOR output IN TEXT MODE ENCODING DEFAULT.
LOOP AT IT_DEMO INTO WA_DEMO.
TRANSFER WA_DEMO TO P_FNAME.
ENDLOOP.
but same issue, sy-subrc is 0, but nothing transfered.
Also there is not CG3Z t code in BI system.
please advice,
‎2011 Sep 15 8:33 PM
‎2011 Sep 15 8:38 PM
‎2011 Sep 15 8:51 PM
this is what i changed to:
>
>
> > OPEN DATASET P_FNAME FOR output IN TEXT MODE ENCODING DEFAULT. > > LOOP AT IT_DEMO INTO WA_DEMO. > > TRANSFER WA_DEMO TO P_FNAME. > > > ENDLOOP. >>
> but same issue, sy-subrc is 0, but nothing transfered.
>
> Also there is not CG3Z t code in BI system.
>
> please advice,
I don't see that you have checked the return code??!!
Rob
‎2011 Sep 15 8:19 PM
Your filename looks kinda funny to me... should be '/usr/sap/tmp/down.txt' I think.
2ndly, Rob is right.
3rdly, do you close the file?
‎2011 Sep 15 8:33 PM
‎2011 Sep 15 8:42 PM
Hi
Have you checked whether the file directory exists in AL11. I am sure the file directory is not correct. Please use some other directory and copy the file path.
I just copied your code and changed the path and got the result
TYPES : BEGIN OF st_demo,
reg_no(10) TYPE c,
name(20) TYPE c,
addr(20) 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 'E:\usr\sap\put\down.txt' OBLIGATORY.
l_fname = p_fname.
wa_demo-reg_no = '100001'.
wa_demo-name = 'ANAND'.
wa_demo-addr = 'NAGARKOVIL'.
APPEND wa_demo TO it_demo.
wa_demo-reg_no = '100002'.
wa_demo-name = 'VIKRAM'.
wa_demo-addr = 'CHENNAI'.
APPEND wa_demo TO it_demo.
OPEN DATASET p_fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
LEAVE LIST-PROCESSING.
ELSE.
WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .
LOOP AT it_demo INTO wa_demo.
IF sy-subrc = 0.
TRANSFER wa_demo TO p_fname.
WRITE :/5 wa_demo-reg_no,16 wa_demo-name,37 wa_demo-addr.
ENDIF.
ENDLOOP.
ENDIF.
Directory: E:\usr\sap\put
Name: DOWN.TXT
100001 ANAND NAGARKOVIL
100002 VIKRAM CHENNAI
‎2011 Sep 15 10:25 PM
‎2011 Sep 15 8:41 PM
Try LOWER CASE infront of OBLIGATORY.
and try '/' instead of '\' in the file if that doesn't work
‎2011 Sep 15 8:41 PM
Try LOWER CASE infront of OBLIGATORY.
and try '/' instead of '\' in the file if that doesn't work
‎2011 Sep 15 8:41 PM
Try LOWER CASE infront of OBLIGATORY.
and try '/' instead of '\' in the file if that doesn't work