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

uploading the data to application server

Former Member
0 Likes
750

Hi,

Can anyone send me a sample program how to upload the data to application server?I have created a report.Here I have a requirement that,in the selection screen,I have to create 2 check boxes(screen,server).If I click on the screen check box the o/p should be displayed on the o/p screen.If I click on the server check box,the o/p should be send to the application server under the directory /usr/sap/axfer/DEV/outbound/ptp/I221/ in the file icat_customer_sap_.txt

Regards,

Hema

7 REPLIES 7
Read only

Former Member
0 Likes
727

Hi Hema,

The following program shows how you can write internal tables into a file:

DATA FNAME(60) VALUE 'myfile'.

TYPES: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

TYPES ITAB TYPE LINE OCCURS 10.

DATA: LIN TYPE LINE,

TAB TYPE ITAB.

DO 5 TIMES.

LIN-COL1 = SY-INDEX.

LIN-COL2 = SY-INDEX ** 2.

APPEND LIN TO TAB.

ENDDO.

OPEN DATASET FNAME FOR OUTPUT.

LOOP AT TAB INTO LIN.

TRANSFER LIN TO FNAME.

ENDLOOP.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT.

DO.

READ DATASET FNAME INTO LIN.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

WRITE: / LIN-COL1, LIN-COL2.

ENDDO.

CLOSE DATASET FNAME.

The output is:

1 1

2 4

3 9

4 16

5 25

In this example, a structure LIN and an internal table TAB with line type LINE are created. Once the internal table TAB has been filled, it is written line by line into the file "myfile". The file is then read into the structure LIN, whose contents are displayed on the screen.

http://help.sap.com/saphelp_470/helpdata/EN/fc/eb3d35358411d1829f0000e829fbfe/frameset.htm

Best regards,

Prashant

Read only

Former Member
0 Likes
727

Hi Hema,

Check this Sample program,

DATA : BEGIN OF WA_CUST_INITIAL,
       STYPE(5),
       CUSTOMER(10),
       Company_Code(10),
       Sales_Organization(10),
       Distribution_Channel(10),
       Division(10),
       Account_Group(10),
       END OF WA_CUST_INITIAL.

DATA : IT_CUST_INITIAL LIKE STANDARD TABLE OF WA_CUST_INITIAL WITH HEADER LINE.

DATA : SOURCE_FILE_INITIAL TYPE STRING VALUE 'C:FLATCUST_INITIAL.TXT'.
DATA : TARGET_FILE_INITIAL(200) VALUE 'D:usrsaptransCUST_INITIAL.TXT'.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = SOURCE_FILE_INITIAL
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'

 TABLES
    DATA_TAB                      = IT_CUST_INITIAL.

OPEN DATASET TARGET_FILE_INITIAL IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.

LOOP AT IT_CUST_INITIAL INTO WA_CUST_INITIAL.
TRANSFER WA_CUST_INITIAL TO TARGET_FILE_INITIAL.
ENDLOOP.
CLOSE DATASET TARGET_FILE_INITIAL.

Thanks,

Reward If Helpful.

Read only

varma_narayana
Active Contributor
0 Likes
727

Hi..Hema..

This is the code to Download the Data to Application server file.

This is the Simple way you can download the ITAB with Tab delimiter:

DATA : V_REC(200).

OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT ITAB INTO WA.

Concatenate WA-FIELD1 WA-FIELD2

INTO V_REC

SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

TRANSFER V_REC TO P_FILE.

ENDLOOP.

CLOSE DATASET P_FILE.

Note: if there are any Numeric fields ( Type I, P, F) In your ITAB then before CONCATENATE you have to Move them to Char fields ..

<b>reward if Helpful.</b>

Read only

0 Likes
727

Hi,

I am able to upload the data to application server.But the o/p fields are getting clubed.There is no gap b/w the fields.How can I get the correct o/p?

Read only

Former Member
0 Likes
727

Hi hema,

<i>APPLSERVER1 = 'D:/USR/SAP/TRANS/ARUNSHORI.TXT'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'filename.txt'

HAS_FIELD_SEPARATOR = '#'

REPLACEMENT = '#'

tables

data_tab = IT_DATA

.

OPEN DATASET APPLSERVER1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT IT_DATA.

TRANSFER IT_DATA TO APPLSERVER1.

ENDLOOP.

CLOSE DATASET APPLSERVER1.

OPEN DATASET APPLSERVER1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

READ DATASET APPLSERVER1 INTO IT_DATA.</i>

Please reward if helpful.

Read only

0 Likes
727

Hi,

Using

OPEN DATASET APPLSERVER1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT data can be uploaded into appl server

What is the use of

OPEN DATASET APPLSERVER1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

READ DATASET APPLSERVER1 INTO IT_DATA.

Read only

Former Member
0 Likes
727

OPEN DATASET FNAME FOR OUTPUT.

LOOP AT TAB INTO LIN.

CONCATENATE LIN-FIELD1

LIN-FIELD2

LIN-FIELD3

<b> into l_text

separated by cl_abap_char_utilities=>Horizontal_tab.

TRANSFER l_text TO FNAME.</b>

ENDLOOP.

CLOSE DATASET FNAME.