‎2008 Feb 12 10:16 AM
Hi
please suggest me code to transfer the file from presentation layer( my desktop) to application layer
Regards
Rasheed,
‎2008 Feb 12 10:24 AM
Hi,
Use fm GUI_UPLOAD to upload the file from presentation server to an internal table. Use OPEN DATASET then TRANSFER and CLOSE DATASET statements to put the internal table to a file on the application server.
I don't know what is the purpose of your query. if you want to upload a file then SAP has provided transactions: CG3Z & CG3Y transactions to do that.
Reward points if useful
rgds,
Harikrishna.
‎2008 Feb 12 10:24 AM
Hi,
Use fm GUI_UPLOAD to upload the file from presentation server to an internal table. Use OPEN DATASET then TRANSFER and CLOSE DATASET statements to put the internal table to a file on the application server.
I don't know what is the purpose of your query. if you want to upload a file then SAP has provided transactions: CG3Z & CG3Y transactions to do that.
Reward points if useful
rgds,
Harikrishna.
‎2008 Feb 12 10:26 AM
hi,
C13Z_FILE_UPLOAD_ASCII Uploads a file in ASCII format
C13Z_FILE_UPLOAD_BINARY Uploads a file in binary format
GUI_UPLOAD Uploads a file from the presentation server
UPLOAD Uploads a file into SAP
UPLOAD_FILES Uploads multiple files into SAP
WS_UPLOAD File transfer to internal table
ALSM_EXCEL_TO_INTERNAL_TABLE Uploads Excel spreadsheet to internal table
KCD_EXCEL_OLE_TO_INT_CONVERT Uploads data directly from Excel sheet
Sample program For upload .
To upload a file from presentation server to application
server we have to do the following :
1. upload the file from presentation server in to an
internal table using gui_upload.
2.open dataset
3.loop the internal table
4.use transfer statement to write into application server
Hope this helps, Do reward.
Edited by: Runal Singh on Feb 12, 2008 3:56 PM
‎2008 Feb 12 10:29 AM
Check the below ones
Downloading files to SAP(Application Server)
http://www.sapdev.co.uk/file/file_downloadsap.htm
Uploading files from SAP(Application Server)
http://www.sapdev.co.uk/file/file_uploadsap.htm
Downloading files to PC(Presentation Server)
http://www.sapdev.co.uk/file/file_downloadpc.htm
Uploading files from PC(Presentation Server)
‎2008 Feb 12 2:26 PM
Hi,
i am giving sampul program.
BDC Program (Application server)
REPORT ZNEWCFINVCHK.
*REPORT ZDEL_FILE_CREATE_IN_APPLI_SER line-size 400.
*
NEW TABLES 20/10/2001 ADDITION START
TABLES : T001W,
MARA,
MCHA,
KNA1.
*
DATA : BEGIN OF ITAB OCCURS 1,
VKORG LIKE VBAK-VKORG , "SALES ORGANIZATION
VTWEG LIKE VBAK-VTWEG, "DISTRIBUTION CHANNEL
DIV(9), "Division Code
VSTEL LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01
DATBI(19), "SELECTION DATE
VGBEL LIKE LIPS-VGBEL, "SALES ORDER "d
KUNNR(10), "SAP CUSTOMER
MATNR LIKE LIPS-MATNR, "MATL NO "d
CHARG LIKE LIPS-CHARG, "BATCH NO "d
LFIMG(13), "DELIVERY QTY "d
free_qty(13), "not used in SAP "d
LTEXT1(9), "PACKING NO
LTEXT2(9), "ALLOCATION NO
LTEXT3(9), "C&F SALES INVOICE NO "d
VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER "d
VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01
DATBI1(19), "SELECTION DATE
END OF ITAB.
data : begin of header_itab occurs 0,
ltext3(9),
end of header_itab.
*******add on 22.10.01
NEW INTERNAL TABLES 20/10/2001 ADDITION START
DATA : BEGIN OF PLANTTAB OCCURS 1,
VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01
VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER
LTEXT3(9), "C&F SALES INVOICE NO
END OF PLANTTAB.
*
DATA : BEGIN OF MATTAB OCCURS 1,
MATNR LIKE LIPS-MATNR, "MATL NO
VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER
LTEXT3(9), "C&F SALES INVOICE NO
END OF MATTAB.
*
DATA : BEGIN OF BATCHTAB OCCURS 1,
MATNR LIKE LIPS-MATNR, "MATL NO
VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01
CHARG LIKE LIPS-CHARG, "BATCH NO
VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER
LTEXT3(9), "C&F SALES INVOICE NO
END OF BATCHTAB.
*
DATA : BEGIN OF CUSTTAB OCCURS 1,
KUNNR(10),
VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER
LTEXT3(9), "C&F SALES INVOICE NO
END OF CUSTTAB.
*
DATA : LINENO LIKE SY-TABIX.
DATA : LINE LIKE SY-TABIX.
data :chk(1).
*
data : begin of errtab occurs 0.
include structure itab.
data : end of errtab.
NEW INTERNAL TABLES 20/10/2001 ADDITION END
*
parameters : fname(80) default '/usr/oldtest/salesorder.txt'
lower case.
parameters : fname_d(80) default '/usr/oldtest/errsalesorder.txt'
lower case.
parameters : fname_n(80) default '/usr/oldtest/newsalesorder.txt'
lower case.
parameters : chngfile as checkbox default 'X'.
*
at selection-screen output.
loop at screen.
if screen-name = 'FNAME' or screen-name = 'FNAME_D' or
screen-name = 'FNAME_N' or screen-name = 'CHNGFILE'.
screen-input = '0'.
modify screen.
endif.
endloop.
start-of-selection.
****************************ECC 6.0 Upgrade Change Start ******************************
*
*Modified by : Sanket on : Date:15.11.2007
*
*Commented code : open dataset fname for input in text mode.
*
*
*
*
*
*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.
*
*Solution: In words
use this statement open dataset <fname> for input in text mode encoding utf-8
*
*Actual (ucommented error free code).
open dataset fname for input in text mode encoding utf-8.
*ENCODING DEFAULT
*WITH SMART LINEFEED.
"encoding utf-8.
*
*
*
***************************ECC 6.0 Upgrade Change End***************************
*open dataset fname for input in text mode.
if sy-subrc eq 0.
do.
clear itab.
read dataset fname into itab.
if sy-subrc <> 0 .
exit.
endif.
append itab.
clear itab.
enddo.
ENDIF.
close dataset fname.
******
NEW VALIDATION 20/10/2001 ADDITION START
LOOP AT ITAB.
*
clear chk.
SELECT SINGLE * FROM T001W WHERE WERKS = ITAB-VSTEL1.
IF SY-SUBRC <> 0.
MOVE : ITAB-VSTEL1 TO PLANTTAB-VSTEL1,
ITAB-VGBEL1 TO PLANTTAB-VGBEL1,
ITAB-LTEXT3 TO PLANTTAB-LTEXT3.
COLLECT PLANTTAB.
CLEAR PLANTTAB.
**251001
move : 'X' to chk.
ENDIF.
*
SELECT SINGLE * FROM MARA WHERE MATNR = ITAB-MATNR.
IF SY-SUBRC <> 0.
MOVE : ITAB-MATNR TO MATTAB-MATNR,
ITAB-VGBEL1 TO MATTAB-VGBEL1,
ITAB-LTEXT3 TO MATTAB-LTEXT3.
COLLECT MATTAB.
CLEAR MATTAB.
**251001
move : 'X' to chk.
ENDIF.
*
SELECT SINGLE * FROM MCHA WHERE MATNR = ITAB-MATNR AND
WERKS = ITAB-VSTEL1 AND
CHARG = ITAB-CHARG.
IF SY-SUBRC <> 0.
MOVE : ITAB-MATNR TO BATCHTAB-MATNR,
ITAB-VSTEL1 TO BATCHTAB-VSTEL1,
ITAB-CHARG TO BATCHTAB-CHARG,
ITAB-VGBEL1 TO BATCHTAB-VGBEL1,
ITAB-LTEXT3 TO BATCHTAB-LTEXT3.
COLLECT BATCHTAB.
CLEAR BATCHTAB.
**251001
move : 'X' to chk.
ENDIF.
*
if not itab-kunnr is initial.
SELECT SINGLE * FROM KNA1 WHERE KUNNR = ITAB-KUNNR.
IF SY-SUBRC <> 0.
MOVE : ITAB-KUNNR TO CUSTTAB-KUNNR,
ITAB-VGBEL1 TO CUSTTAB-VGBEL1,
ITAB-LTEXT3 TO CUSTTAB-LTEXT3.
COLLECT CUSTTAB.
CLEAR CUSTTAB.
**251001
move : 'X' to chk.
ENDIF.
endif.
*
if chk = 'X'.
if not itab-vkorg is initial.
move itab-ltext3 to header_itab-ltext3.
append header_itab.
clear header_itab.
endif.
move-corresponding itab to errtab.
append errtab.
delete itab.
endif.
*
ENDLOOP.
*
loop at itab.
read table header_itab with key ltext3 = itab-ltext3.
if sy-subrc = 0.
move-corresponding itab to errtab.
append errtab.
delete itab.
endif.
endloop.
*
Deleted Records from itab.
DESCRIBE TABLE ERRTAB LINES LINE.
WRITE : 'DELETED RECORDS FROM ITAB.' COLOR 4 ,LINE .
ULINE.
*
LOOP AT ERRTAB.
WRITE : /1 ERRTAB-MATNR,
ERRTAB-CHARG,
ERRTAB-VGBEL1,
ERRTAB-VSTEL1,
ERRTAB-LTEXT3.
ENDLOOP.
*
****************************ECC 6.0 Upgrade Change Start ******************************
*
*Modified by : Sanket on : Date:15.11.2007
*
*Commented code : open dataset fname_d for output in text mode.
*
*
*
*
*
*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.
*
*Solution: In words
use this statement open dataset <fname_d> for output in text mode encoding utf-8
*
*Actual (ucommented error free code).
open dataset fname_d for output in text mode encoding utf-8.
*
*
*
***************************ECC 6.0 Upgrade Change End***************************
*open dataset fname_d for output in text mode.
loop at errtab.
transfer errtab to fname_d.
endloop.
close dataset fname_d.
*
if not chngfile is initial.
****************************ECC 6.0 Upgrade Change Start ******************************
*
*Modified by : Sanket on : Date:03.10.2007
*
*Commented code : open dataset fname_n for output in text mode.
*
*
*
*
*
*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.
*
*Solution: In words
use this statement open dataset <fname_n> for output in text mode encoding utf-8
*
*Actual (ucommented error free code).
open dataset fname_n for output in text mode encoding utf-8.
*
*
*
***************************ECC 6.0 Upgrade Change End***************************
open dataset fname_n for output in text mode.
loop at itab.
transfer itab to fname_n.
endloop.
close dataset fname_n.
endif.
WRITE MISSING PLANTS
DESCRIBE TABLE PLANTTAB LINES LINENO.
IF LINENO > 0.
WRITE : /1 'Missing plants.' COLOR 4.
ULINE.
SORT PLANTTAB.
LOOP AT PLANTTAB.
WRITE : /1 PLANTTAB-VSTEL1 COLOR 2,
PLANTTAB-VGBEL1 COLOR 2,
PLANTTAB-LTEXT3 COLOR 2.
ENDLOOP.
ELSE.
WRITE : /1 'No plants missing.'.
ENDIF.
*
*
WRITE MISSING MATERIALS
DESCRIBE TABLE MATTAB LINES LINENO.
IF LINENO > 0.
WRITE : /1 'Missing materials.' COLOR 4.
ULINE.
SORT MATTAB.
LOOP AT MATTAB.
WRITE : /1 MATTAB-MATNR COLOR 2,
MATTAB-VGBEL1 COLOR 2,
MATTAB-LTEXT3 COLOR 2.
ENDLOOP.
ELSE.
WRITE : /1 'No materials missing.'.
ENDIF.
*
WRITE MISSING BATCHES
DESCRIBE TABLE BATCHTAB LINES LINENO.
IF LINENO > 0.
WRITE : /1 'Missing material/plants/batch.' COLOR 4 , LINENO.
ULINE.
SORT BATCHTAB.
LOOP AT BATCHTAB.
WRITE : /1 BATCHTAB-MATNR COLOR 2,
BATCHTAB-VSTEL1 COLOR 2,
BATCHTAB-CHARG COLOR 2,
BATCHTAB-VGBEL1 COLOR 2,
BATCHTAB-LTEXT3 COLOR 2.
ENDLOOP.
ELSE.
WRITE : /1 'No material/plant/batch missing.'.
ENDIF.
*
WRITE MISSING BATCHES
DELETE CUSTTAB WHERE KUNNR EQ SPACE.
DESCRIBE TABLE CUSTTAB LINES LINENO.
IF LINENO > 0.
WRITE : /1 'Missing Customers.' COLOR 4.
ULINE.
SORT CUSTTAB.
LOOP AT CUSTTAB.
WRITE : /1 CUSTTAB-KUNNR COLOR 2,
CUSTTAB-VGBEL1 COLOR 2,
CUSTTAB-LTEXT3 COLOR 2.
ENDLOOP.
ELSE.
WRITE : /1 'No Customer missing.'.
ENDIF.
NEW VALIDATION 20/10/2001 ADDITION END