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

FM to upload the Internal table data into application server.

Former Member
0 Likes
4,166

Hi,

Could you please give me Function module to Upload the Internal table data into Application server ie., in Tcode AL11.

I know for downloading the Application server file into itab is "SUBST_GET_FILE_LIST" FM and using open dtaa set we get the data.

Regards,

deepthi.

Hi,

Could you please give me Function module to Upload the Internal table data into Application server ie., in Tcode AL11.

I know for downloading the Application server file into itab is "SUBST_GET_FILE_LIST" FM and using open dtaa set we get the data.

Regards,

deepthi.

10 REPLIES 10
Read only

GauthamV
Active Contributor
0 Likes
2,137

I dont think you have any direct FM for that.

You can use CG3Y,CG3Z transactions to upload flatfile directly or

use Dataset statements to upload from internal table to application server.

Read only

Former Member
0 Likes
2,137

Hi,

typeS: BEGIN OF t_dwnld,

ebeln TYPE ebeln,

bsart TYPE esart,

ernam TYPE ernam,

aedat(10) TYPE c, "erdat,

lifnr TYPE lifnr,

name1 TYPE name1_gp,

ekorg TYPE ekorg,

bkgrp TYPE bkgrp,

bukrs TYPE bukrs,

zterm TYPE dzterm,

extyp TYPE zzexptype,

  • hdtxt TYPE string,

ebelp TYPE ebelp,

pstyp TYPE pstyp,

knttp TYPE knttp,

vrtkz TYPE vrtkz,

zekkn TYPE dzekkn,

vproz TYPE vproz,

txz01 TYPE txz01,

matkl TYPE matkl,

eindt(10) TYPE c, " TYPE eindt,

werks TYPE werks_d,

menge TYPE bstmg,

meins TYPE bstme,

netpr TYPE bprei,

afnam TYPE afnam,

bednr TYPE bednr,

mwskz TYPE mwskz,

adrn2 TYPE adrn2,

totgr TYPE menge_d,

opqty TYPE menge_d,

paqty TYPE menge_d,

pckno TYPE packno,

sbpck TYPE sub_packno,

linum TYPE srv_line_no,

extln TYPE extrow,

srtxt TYPE sh_text1,

srqty TYPE mengev,

srbum TYPE meins,

sgrpc TYPE bapigrprice,

saqty TYPE act_menge,

stogr TYPE mengev,

sopqt TYPE mengev,

spaqt TYPE mengev,

sakto TYPE saknr,

kostl TYPE kostl,

nplnr TYPE nplnr,

actvt(4) TYPE c,

sub TYPE zzsub,

wbs(24) TYPE c, "ps_psp_pnr,

asset TYPE anln1,

delid TYPE eloek,

END OF t_dwnld,

i_dwnld type standard table of t_dwnld,

wa_dwnld type t_dwnld.

  • transfering data from ITAB to Application server

DATA : path TYPE string.

path = 'E:\usr\sap\trans\ZTOTAL_SERVICE_PO.csv'.

LOOP AT i_dwnld INTO wa_dwnld.

  • REPLACE ALL OCCURRENCES OF '#' IN wa_dwnld WITH ''.

TRANSFER wa_dwnld TO path.

ENDLOOP.

CLOSE DATASET path.

In application server, teh data is stored with '#' how to remove it. adn i need a excel file in the application server path.

Regards,

Deepthi.

Read only

Former Member
0 Likes
2,137

Hi Deepthi

Incase you are looking to upload data in the AL11 through a program , then you can make use of OPEN DATASET...CLOSE DATASET statements.

Here's the code snippet:

IF tb_alvdisplay[] IS INITIAL.

MESSAGE e999(/dcsea/zais_msg) WITH text-e01.

ELSE.

IF NOT cb_ufile IS INITIAL "Download to file

AND sy-pagno = 0. "Only down page headers for first page

PERFORM fm_concatenate_path_name USING p_path

p_file

CHANGING v_file.

*Open file for download.

PERFORM fm_open_file USING v_file .

ENDIF.

LOOP AT tb_alvdisplay.

IF NOT cb_ufile IS INITIAL.

*Passing the values of the respective headings to the structure.

ws_rec-vend_no = tb_alvdisplay-vendno.

ws_rec-vend_nm = tb_alvdisplay-vendnm.

ws_rec-title = tb_alvdisplay-vendtl.

ws_rec-add = tb_alvdisplay-add.

ws_rec-city1 = tb_alvdisplay-city1.

ws_rec-region = tb_alvdisplay-region.

ws_rec-country = tb_alvdisplay-country.

ws_rec-pobox = tb_alvdisplay-po.

ws_rec-phone = tb_alvdisplay-telf1.

ws_rec-extn = tb_alvdisplay-extn.

ws_rec-fax = tb_alvdisplay-telfx.

ws_rec-zterm = tb_alvdisplay-zterm.

ws_rec-remark = tb_alvdisplay-remark.

ws_rec-email = tb_alvdisplay-email.

*Passing the separator 'PIPE' to the structure.

ws_rec-sep01 = co_sep.

ws_rec-sep02 = co_sep.

ws_rec-sep03 = co_sep.

ws_rec-sep04 = co_sep.

ws_rec-sep05 = co_sep.

ws_rec-sep06 = co_sep.

ws_rec-sep07 = co_sep.

ws_rec-sep08 = co_sep.

ws_rec-sep09 = co_sep.

ws_rec-sep10 = co_sep.

ws_rec-sep11 = co_sep.

ws_rec-sep12 = co_sep.

ws_rec-sep13 = co_sep.

TRANSFER ws_rec TO v_file.

ENDIF.

AT LAST.

IF NOT cb_ufile IS INITIAL.

*Closing the DATASET file.

CLOSE DATASET v_file.

IF sy-subrc <> 0.

*Failure Message.

MESSAGE e999(/dcsea/zais_msg) WITH text-t04 text-t06.

ELSE.

*Success message.

MESSAGE s999(/dcsea/zais_msg) WITH text-t05.

ENDIF.

ENDIF.

ENDAT.

ENDLOOP.

ENDIF.

Also as Gautham suggested you can use tcode CG3Z or CG3Y incase you are looking to upload the data directly.

FInally, you can search SCN using the keywords, "Upload to AL11" and you'll get loads of results.

Hope this helps.

Harsh

Read only

0 Likes
2,137

please correct my code which is mentioned above.

Read only

0 Likes
2,137

Hi Deepthi

Your code looks OK to me.

Just pass the output fields with their values and the separator before the TRANSFER statement.

Copy the code i pasted previously and let me know if you have any doubts.

Regards

Harsh

Read only

0 Likes
2,137

Hi,

Did you check in debugging mode whether 'replace' is working or not?


Loop  i_dwnld INTO wa_dwnld.
REPLACE ALL OCCURRENCES OF '#' IN wa_dwnld WITH ' '.
MODIFY i_dwnld FROM wa_dwnld .
Endloop.

TRANSFER  i_dwnld TO path.

Try this code. I think it should work.

Thanks,

Archana

Read only

0 Likes
2,137

what si teh data type of ws_rec

Read only

0 Likes
2,137

TYPES : t_sep(1).

  • Structure for holding all the values while downloading to sap server

DATA : BEGIN OF ws_rec,
         vend_no(20),
         sep01 TYPE t_sep,
         vend_nm(30),
         sep02 TYPE t_sep,
         title(30),
         sep03 TYPE t_sep,
         add(70),
         sep04 TYPE t_sep,
         city1(40),
         sep05 TYPE t_sep,
         region(3),
         sep06 TYPE t_sep,
         country(40),
         sep07 TYPE t_sep,
         pobox(40),
         sep08 TYPE t_sep,
         phone(15),
         sep09 TYPE t_sep,
         extn(10),
         sep10 TYPE t_sep,
         fax(20),
         sep11 TYPE t_sep,
         remark(60),
         sep12 TYPE t_sep,
         email(40),
         sep13 TYPE t_sep,
         zterm(20),
      END OF ws_rec.

Read only

kanishakgupta1
Contributor
0 Likes
2,137

Hi ,

Please find the ZFM to upload the data to app server...

FUNCTION zput_data_app_server .
  CONSTANTS:
        con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
  TYPES: BEGIN OF itab_type,
          word(255) TYPE c,
        END   OF itab_type.
  DATA: it_tab TYPE TABLE OF itab_type.
  DATA: wa_tab TYPE itab_type.
  DATA: l_ref_table_des TYPE REF TO cl_abap_structdescr.
  DATA: ist_details TYPE abap_compdescr_tab.
  DATA: wa_details TYPE abap_compdescr.
  DATA: lv_loop TYPE sy-index.
  DATA: wa_string TYPE string.   "0001
  data: lv_strlen type i.
  FIELD-SYMBOLS:
    <lf_tab> TYPE ANY TABLE,
    <lf_wa>,
    <lf_field>.
  DATA l_dy_line  TYPE REF TO data.
  CREATE DATA l_dy_line LIKE LINE OF p_record.
  ASSIGN l_dy_line->* TO <lf_wa>.
*fecth  columns from of dynamic work area
  l_ref_table_des ?=
      cl_abap_typedescr=>describe_by_data( <lf_wa> ).
  ist_details[] = l_ref_table_des->components[].
*Count number of fields in structure
  DESCRIBE TABLE ist_details LINES lv_loop.
  TRY.
      OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        RAISE file_open_error.
      ELSE.
        LOOP AT p_record.
          CLEAR: wa_string.
          DO lv_loop TIMES .
            ASSIGN COMPONENT sy-index OF STRUCTURE p_record TO <lf_field>.
            CONCATENATE  wa_string <lf_field> INTO wa_string. "0003
            if lv_loop > sy-index.                            "0003
              CONCATENATE  wa_string con_tab INTO wa_string.  "0003
            ENDIF.                                            "0003
          ENDDO.
          TRANSFER wa_string TO p_file.
        ENDLOOP.
        CLOSE DATASET p_file.
      ENDIF.
    CATCH cx_sy_file_authority.
      RAISE file_open_error.
    CATCH cx_sy_conversion_codepage.
      RAISE file_open_error.
  ENDTRY.
ENDFUNCTION.

Read only

Former Member
0 Likes
2,137

it is solved.