2007 May 18 5:21 AM
Hi all,
I have implemented the logic in uploading data into application server. my problem is even though sy-subrc=0 for open dataset ,the data is not uploading into application server. kindly help me.
Thanks,
Praveena
2007 May 18 5:29 AM
Hi
Check the code in Debugging, where it is going wrong exactly.
Open dataset.
if sy-subrc = 0.
loop at itab.
transfer data to file.
endloop.
endif.
close dataset.
Reward points if useful
Regards
Anji
Hi
Check the code in Debugging, where it is going wrong exactly.
Open dataset.
if sy-subrc = 0.
loop at itab.
transfer data to file.
endloop.
endif.
close dataset.
Reward points if useful
Regards
Anji
2007 May 18 5:29 AM
Hi
Check the code in Debugging, where it is going wrong exactly.
Open dataset.
if sy-subrc = 0.
loop at itab.
transfer data to file.
endloop.
endif.
close dataset.
Reward points if useful
Regards
Anji
2007 May 18 5:37 AM
Hi Anji Reddy,
I have written the code like that only. i am giving my code here.kindly tell me where i am going wrong.
thanks,
Praveena
REPORT ZDOWNLOAD .
----
T A B L E S
----
*Tables
Tables: YCOSTCTR, " To maintain Substitution data for Cost Centers
KNVV. " Customer Master Sales Data
----
T A B L E T Y P E S
----
TYPES: BEGIN OF ty_final,
KUNWE TYPE KUNWE, "Ship-to party
KOSTL TYPE KOSTL, "Cost-Center
EIKTO TYPE EIKTO, "Shipper's(Our)Acc No.at the Customer or Vendor
leg_dep(4) type c, "Legacy Department
END OF ty_final.
TYPES: BEGIN OF ty_ycostctr,
KUNWE TYPE KUNWE, "Ship-to party
KOSTL TYPE KOSTL, "Cost-Center
leg_dep(4) type c, "Legacy Department
END OF ty_ycostctr.
TYPES: BEGIN OF ty_ycostctr1,
KUNWE TYPE KUNWE, "Ship-to party
KOSTL TYPE KOSTL, "Cost-Center
END OF ty_ycostctr1.
TYPES: BEGIN OF ty_knvv,
KUNNR TYPE KUNNR, "Customer Number 1
EIKTO TYPE EIKTO, "Shipper's(Our)Acc No.at the Customer or Vendor
END OF ty_knvv.
----
I N T E R N A L T A B L E S
----
DATA: tb_ycostctr TYPE STANDARD TABLE OF ty_ycostctr.
DATA: tb_ycostctr1 TYPE STANDARD TABLE OF ty_ycostctr1.
DATA: tb_knvv TYPE STANDARD TABLE OF ty_knvv.
final internal table to upload into application server
DATA: tb_final TYPE STANDARD TABLE OF ty_final.
----
W O R K A R E A S
----
DATA: wa_ycostctr TYPE ty_ycostctr.
DATA: wa_ycostctr1 TYPE ty_ycostctr1.
DATA: wa_knvv TYPE ty_knvv.
DATA: wa_final TYPE ty_final.
----
V A R I A B L E S
----
DATA:
l_filenm LIKE filename-fileintern,
logical file name for interface
c_lg_ar LIKE filename-fileintern VALUE 'Z_21767_COSTCTR_OUTBOUND',
l_out_file(255).
DATA: l_filename TYPE file_name.
----
C O N S T A N T S
----
DATA: e_file like rlgrap-filename value
'usr/sap/interfaces/<SYSID>/inbound/ctmvendor/costctr_inbound.txt'.
----
S E L E C T I O N S C R E E N
----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE INPUT.
PARAMETERS : p_file TYPE filename-fileintern.
default '/usr/sap/interfaces/D48/outbound/test_cost1'.
SELECTION-SCREEN END OF BLOCK b1.
----
I N I T I A L I Z A T I O N
----
INITIALIZATION.
l_filenm = c_lg_ar.
PERFORM transfer_to_file USING l_filenm.
p_file = l_out_file.
----
A T S E L E C T I O N - S C R E E N
----
----
S T A R T - O F - S E L E C T I O N
----
start-of-selection.
to get data into final internal table
PERFORM get_data.
----
E N D - O F - S E L E C T I O N
----
end-of-selection.
PERFORM upload using p_file.
----
F O R M S
----
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
form get_data .
select kunwe
kostl
into table tb_ycostctr1
from ycostctr.
Delete adjacent duplicates from tb_ycostctr1 comparing kunwe kostl.
select kunnr
eikto
into table tb_knvv
from knvv
for all entries in tb_ycostctr1
where kunnr = tb_ycostctr1-kunwe.
if sy-subrc = 0.
To get data into final internal table.
loop at tb_ycostctr1 into wa_ycostctr1 .
READ TABLE tb_knvv INTO wa_knvv
WITH KEY kunnr = wa_ycostctr1-kunwe.
if sy-subrc = 0.
wa_final-kunwe = wa_ycostctr1-kunwe.
wa_final-kostl = wa_ycostctr1-kostl.
wa_final-eikto = wa_knvv-eikto.
wa_final-leg_dep = wa_ycostctr1-kostl+6(4).
append wa_final to tb_final.
endif.
endloop.
endif.
endform. " get_data
&----
*& Form upload
&----
text
----
--> p1 text
<-- p2 text
----
form upload using p_file.
l_filename = l_out_file.
OPEN DATASET l_filename FOR OUTPUT IN TEXT MODE ENCODING
UTF-8 IGNORING CONVERSION ERRORS.
*OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING
UTF-8 IGNORING CONVERSION ERRORS.
if sy-subrc = 0.
LOOP AT tb_final INTO wa_final.
TRANSFER wa_final TO l_filename .
clear wa_final.
TRANSFER wa_final TO p_file .
ENDLOOP.
CLOSE DATASET l_filename.
CLOSE DATASET p_file.
endif.
endform. " upload
&----
*& Form transfer_to_file
&----
text
----
-->P_L_FILENM text
----
form transfer_to_file using p_filenm.
Check if program in background should download to UNIX
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = p_filenm
IMPORTING
file_name = l_out_file
EXCEPTIONS
OTHERS = 1.
IF NOT sy-subrc IS INITIAL.
write: 'error'.
ENDIF.
endform. " transfer_to_file
2007 May 18 6:02 AM
hi
good
i go through your code,i feel three things you have see here.
1-Check what data you r geting in the intenal table after the select statement,
2-Then you check the opendata set query that you have written to uploading the data
thanks
mrutyun^
2007 May 18 6:08 AM
Hi all,
I have a doubt. if there is no directory in the application server what happens? means.. if i have the path like
'/usr/sap/interfaces/Server/outbound/dir1/data/'
if i dont have the directory 'dir1' then where the data will be uploaded.what is the subrc value here.
Kindly help me.
Thanks,
Praveena.
2007 May 18 6:12 AM
Hi Sri,
Thne it iwll through the error message which u mentioned in the condition sy-surc <> 0.
Reply for qureis. Shall post the updates,
Regards,
Kumar.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |