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

sending file to application server

Former Member
0 Likes
815

Hi All,

i've 20 fields in my internal table.i need to send these fields into application server as tab delimated.

how can i concatenate these fileds into other internal table as

tab delimated in simple way.

thanks & regards

rahul

Hi All,

i've 20 fields in my internal table.i need to send these fields into application server as tab delimated.

how can i concatenate these fileds into other internal table as

tab delimated in simple way.

thanks & regards

rahul

6 REPLIES 6
Read only

Former Member
0 Likes
748

Hi,

REfer This Code:

REPORT ZGILL_AS message-id rp .

parameters: P_DSNI(75) TYPE C MODIF ID ABG DEFAULT

'/usr/local/sapdata/amit.dat' LOWER CASE.

data: begin of itab occurs 0,

pernr(8),

sp1(1) value ',',

werks(4),

sp2(1) value ',',

persg(1),

sp3(1) value ',',

persk(2),

end of itab.

OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.

PERFORM FETCH_DATA.

&----


*& Form FETCH_DATA

&----


text

-


--> p1 text

<-- p2 text

-


FORM FETCH_DATA .

SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.

MOVE-CORRESPONDING PA0001 TO ITAB.

TRANSFER ITAB TO P_DSNI.

APPEND ITAB.

ENDSELECT.

CLOSE DATASET P_DSNI.

ENDFORM. " FETCH_DATA

Refer This Link:

Regards,

Kumar

Read only

Former Member
0 Likes
748

hi,

concatenate all your fields into a workarea seprated by space and send this to application server.

reward points if it is helpful.

Regards,

Srilatha.

Read only

0 Likes
748

Hi Srilu,

I want the fileds as separated by tab delimated

Read only

Former Member
0 Likes
748

Hi Rahul ,

check this code..

FORM write_applserv.

CLEAR: wa_output,

wf_path.

  • Function to get the file name and path

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

client = sy-mandt

logical_filename = 'Z_

operating_system = sy-opsys

IMPORTING

file_name = wf_path

EXCEPTIONS

file_not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

wf_empty_flag = 1.

  • If file path does not exist then Exit.

EXIT.

ENDIF.

  • Convert the date to short-time-stamp.

*

TRANSLATE wf_path TO LOWER CASE.

CONCATENATE wf_path co_r wf_timestamp_c co_dat

INTO wf_filename.

TRANSLATE wf_filename TO LOWER CASE.

IF NOT tb_output[] IS INITIAL. "

OPEN DATASET wf_filename FOR OUTPUT IN TEXT MODE.

IF sy-subrc <> 0.

wf_empty_flag = 3.

EXIT.

ENDIF.

ENDIF.

CLEAR : wf_temp,

wf_temp1,

wf_temp2,

  • wf_temp3,

wf_temp4,

wf_temp5,

wf_temp6,

wf_temp7,

wa_output,

wa_output1.

IF NOT tb_output[] IS INITIAL.

LOOP AT tb_output INTO wa_output.

wf_temp = wa_output-z_net_amnt.

wf_temp1 = wa_output-z_amnt.

wf_temp2 = wa_output-z_opt_amnt.

  • wf_temp3 = wa_output-z_opt_amnt.

wf_temp4 = wa_output-z_disc_amnt.

wf_temp5 = wa_output-z_misc_amnt.

wf_temp6 = wa_output-z_vat_amnt.

wf_temp7 = wa_output-z_margn_amnt.

CONDENSE wf_temp NO-GAPS.

CONDENSE wf_temp1 NO-GAPS.

CONDENSE wf_temp2 NO-GAPS.

CONDENSE wf_temp4 NO-GAPS.

CONDENSE wf_temp5 NO-GAPS.

CONDENSE wf_temp6 NO-GAPS.

CONDENSE wf_temp7 NO-GAPS.

*

  • SHIFT :

  • wf_temp LEFT DELETING LEADING space,

  • wf_temp1 LEFT DELETING LEADING space,

  • wf_temp2 LEFT DELETING LEADING space,

  • wf_temp4 LEFT DELETING LEADING space,

  • wf_temp5 LEFT DELETING LEADING space,

  • wf_temp6 LEFT DELETING LEADING space,

  • wf_temp7 LEFT DELETING LEADING space.

CONCATENATE wa_output-z_vhvin

wa_output-z_c

wa_output-z_lic

wa_output-z_lic

wa_output-z_kun

wa_output-z_vh

wa_output-z_off

wa_output-z_v

wa_output-z_do

wa_output-z_fka

wf_temp

wf_temp1

wf_temp2

  • wf_temp3

wf_temp4

wf_temp5

wf_temp6

wf_temp7

wa_output-z_de

wa_output-z_ge

INTO wa_output1

SEPARATED BY co_tab.

  • CONDENSE wa_output1 NO-GAPS.

TRANSFER wa_output1 TO wf_filename.

  • TRANSFER wa_output4 TO wf_filename.

CLEAR : wa_output1,

wa_output.

ENDLOOP.

CLOSE DATASET wf_filename.

ELSE.

    • If output internal table is not filled.

    • Pass an empty record.

  • TRANSFER wa_output1 TO wf_filename.

wf_empty_flag = 4. "2. "chouhanm 5.5.08

ENDIF.

  • CLOSE DATASET wf_filename.

ENDFORM. " write_applserv

Use this in global declarations for co_tab.

co_tab(1) TYPE x VALUE '09',

cheers,

Edited by: Mohinder Singh Chauhan on May 13, 2008 7:22 AM

Read only

Former Member
0 Likes
748

Hi Rahul,

Pls find below for the sample code to create a file in application server.

REPORT zb_test.

* Declare your internal table (IT_TEST) which is used to collect all the data and send to Application server.

  • Type Declaration For Final Internal Table.

TYPES: ty_lfinal TYPE string , "Final Data with tab delimiter

ty_t_final TYPE STANDARD TABLE OF ty_lfinal . " Final Data

DATA:

it_final TYPE ty_t_final , " Final Internal Table

wa_final TYPE ty_lfinal ,

l_final TYPE string .

*

*

  • Do the necessary code to collect all the data which are send to App. Server.

Loop at IT_TEST into WA_TEST.

CONCATENATE WA_TEST-FIELD1……….WA_TEST20

INTO l_final

SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

MOVE l_final TO wa_final.

APPEND wa_final TO it_final.

ENDLOOP.

CALL METHOD cl_rsan_ut_appserv_file_writer=>appserver_file_write

EXPORTING

i_filename = l_filename_tmp “ Application Server File Path

i_overwrite = space

i_data_tab = it_final

EXCEPTIONS

open_failed = 1

write_failed = 2

close_failed = 3

OTHERS = 4.

  • Send Error Message If File Process Exceptions Raised

IF sy-subrc <> 0.

CASE sy-subrc.

WHEN 1.

g_error_text = text-013. " 'File Open Error'(013).

WHEN 2.

g_error_text = text-014. " 'Data Write To File Error'(014).

WHEN 3.

g_error_text = text-015. " 'File Close Error'(015).

WHEN OTHERS.

g_error_text = text-011. " 'Others'(011).

ENDCASE.

Message (8i) with g_error_text.

Read only

manubhutani
Active Contributor
0 Likes
748

Hi i think u need to insert fields in the structure

after evey field which has spaces of a tab

Please reward points if useful.