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

Data Transfer to Application Server

Former Member
0 Likes
918

Hi friends,

I have a requirement to wirte data to application server. this is ok.

but what i need is, i am not just following the same structure of data.

the data in the program is like this

abcd 123 4566666

abcd 124 4566667

abcd 125 4566668

i want to write this using TRANSFER like below

1 abcd

2 123 4566666

2 124 4566667

2 125 4566668.

this is an example.,

appreciate your help. points will be rewarded.

Thanks a lot.

9 REPLIES 9
Read only

Former Member
0 Likes
877

Hi,

What should be output for the next set of data.

Ex..

<b>Input</b>

abcd 123 4566666

abcd 124 4566667

abcd 125 4566668

<b>bcde 123 4566666

bcde 124 4566667

bcde 125 4566668</b>

<b>Output</b>

1 abcd

2 123 4566666

2 124 4566667

2 125 4566668

?????

Thanks,

Naren

Read only

0 Likes
877

Hi Naren

1 abcd

2 123 4566666

2 124 4566667

2 125 4566668

1 bcde

2 123 4566666

2 124 4566667

2 125 4566668

this is the next set of data.

Read only

0 Likes
877

See my solution above.

Read only

Former Member
0 Likes
877

Assuming your internal table (itab) has columns a, b and c, you could use the following:


LOOP AT itab.
  AT NEW a.
    CONCATENATE '1' itab-a INTO l_string SEPARATED BY SPACE.
    TRANSFER l_string TO l_file.
  ENDAT.

  CONCATENATE '2' itab-b itab-c INTO l_string
      SEPARATED BY SPACE.
  TRANSFER l_string TO l_file.
ENDLOOP.

Read only

Former Member
0 Likes
877

Hi Kiran,

You can do something like this.



IF NOT p_err IS INITIAL.

  OPEN DATASET p_err FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_message.
  IF sy-subrc IS INITIAL.
    LOOP AT t_results.

      ON CHANGE OF t_results-field1.

        w_count = w_count + 1.
        CONCATENATE w_count t_results-field1 INTO w_temp.
        TRANSFER w_temp TO p_err.  " Transfer t_results-field1 only
        CONTINUE.
        w_count = w_count + 1.

      ENDON.

      CONCATENATE w_count t_results-field2 t_results-field3 INTO w_temp.
      TRANSFER w_temp TO p_err.    " Transfer t_results-field2 t_results-field3 only


    ENDLOOP.

    CLOSE DATASET p_err.

  ELSE.

    MESSAGE w_message TYPE 'E' DISPLAY LIKE 'S'.
    LEAVE LIST-PROCESSING.

  ENDIF.



ENDIF.

Will try to write full code. Tomo. Good Night.

Regards,

AS

Read only

ferry_lianto
Active Contributor
0 Likes
877

Hi Kiran,

Please try this.

DATA: WA_OUTPUT TYPE STRING. 
DATA: WA_SEQ TYPE I.

OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE. 

SORT ITAB.
LOOP AT ITAB.
  AT NEW <itab-field1>.
    WA_SEQ = WA_SEQ + 1.
    CONCATENATE WA_SEQ ITAB-<FIELD1> 
                INTO WA_OUTPUT SEPARATED BY SPACE.
    TRANSFER WA_OUTPUT TO P_FILE.
  ENDAT.
 
  CONCATENATE WA_SEQ ITAB-<FIELD2> ITAB-<FIELD3>
              INTO WA_OUTPUT SEPARATED BY SPACE.
  TRANSFER WA_OUTPUT TO P_FILE.
ENDLOOP.

CLOSE DATASET P_FILE.

Hope this will help.

Regards,

Ferry Lianto

Read only

0 Likes
877

Thank you very much all.

ferry, after this i need to read the file from application server. so in Apllication server will it be stored as tab delimmited text file???

thanks once again.

Read only

Former Member
0 Likes
877

Hi,

Check Michael Malvey's reply..That should work..

One small addition..Add a sort statement for the column "a" mention in his post to group the records..

SORT ITAB BY a.

Thanks,

Naren

Read only

ferry_lianto
Active Contributor
0 Likes
877

Hi Kiran,

The file will be stored as flat file (not tab delimmited) in application server.

But you can try this to save with tab delimited.

DATA: WA_OUTPUT TYPE STRING.

DATA: WA_SEQ TYPE I.

CONSTANTS: C_TAB TYPE X VALUE '09'.

OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.

SORT ITAB.

LOOP AT ITAB.

AT NEW <ITAB-FIELD1>.

WA_SEQ = WA_SEQ + 1.

CONCATENATE WA_SEQ C_TAB ITAB-<FIELD1>

INTO WA_OUTPUT.

TRANSFER WA_OUTPUT TO P_FILE.

ENDAT.

CONCATENATE WA_SEQ C_TAB ITAB-<FIELD2> C_TAB ITAB-<FIELD3>

INTO WA_OUTPUT.

TRANSFER WA_OUTPUT TO P_FILE.

ENDLOOP.

CLOSE DATASET P_FILE.

Regards,

Ferry Lianto

Please reward points if helpful.