Skip to Content
author's profile photo Former Member
Former Member

How to dynamic field insert into intenal table?

hi friends

this is my urgent requirements .... how to dynamic field insert into internal table if it possible please tell me

thanks & regards

pauldharma

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 30, 2008 at 05:50 AM

    Hi,

    Go through this

    REPORT yusmm_text1 NO STANDARD PAGE HEADING

    LINE-SIZE 199.

    ************************************************************************

    • T A B L E S

    ************************************************************************

    TABLES: MARA,

    MAKT,

    THEAD.

    ********************************************************************

    • GLOBAL TYPE-POOLS

    ********************************************************************

    TYPE-POOLS : SLIS.

    ********************************************************************

    • GLOBAL TYPES

    ********************************************************************

    TYPES : BEGIN OF TP_FINAL,

    MATNR TYPE MARA-MATNR,

    BEGRU TYPE MARA-BEGRU,

    MTART TYPE MARA-MTART,

    MAKTX TYPE MAKT-MAKTX,

    SPRAS TYPE MAKT-SPRAS,

    LTXT(2000) TYPE C ,

    SRNO TYPE N ,

    END OF TP_FINAL.

    TYPES : BEGIN OF TP_T002,

    SPRAS TYPE T002-SPRAS,

    LAISO TYPE T002-LAISO,

    SRNO TYPE N ,

    END OF TP_T002.

    TYPES : BEGIN OF TP_MARA_MAKT,

    MATNR TYPE MARA-MATNR,

    BEGRU TYPE MARA-BEGRU,

    MTART TYPE MARA-MTART,

    SPRAS TYPE MAKT-SPRAS,

    MAKTX TYPE MAKT-MAKTX,

    END OF TP_MARA_MAKT.

    Types: BEGIN OF tp_matnr,

    matnr TYPE mara-matnr,

    END OF tp_matnr.

    • ********************************************************************

    • GLOBAL ELEMENTARY VARIABLES

    *

    *********************************************************************

    DATA : gv_date TYPE sy-datum.

    DATA : gv_repid TYPE sy-repid.

    DATA : g_var1(10) TYPE C.

    DATA : gv_index TYPE sy-tabix.

    DATA: gv_strg TYPE string,

    gv_strg1(2000) TYPE C.

    DATA : gv_lang TYPE sy-langu.

    DATA : g_v(3) TYPE N .

    DATA : gv_lines(3) TYPE N .

    DATA : gv_var(3) TYPE N .

    DATA : gv_var1(3) TYPE N.

    DATA: gv_str TYPE STRING.

    DATA: gv_str1 TYPE STRING.

    DATA : gv_li TYPE I,

    gv_lit TYPE I,

    gv_lin TYPE I.

    DATA: g_var11(3) TYPE N,

    gv_li1(3) TYPE N,

    g_var2(3) TYPE N.

    DATA : gv_i1 TYPE I.

    DATA : gv_i TYPE I.

    DATA: gl_lenght TYPE I.

    *********************************************************************

    • GLOBAL STRUCTURES

    ******************************************************

    DATA: T_NEWTABLE TYPE REF TO DATA,

    T_NEWLINE TYPE REF TO DATA,

    T_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

    T_FLDCAT TYPE LVC_T_FCAT,

    WA_IT_FLDCAT TYPE LVC_S_FCAT,

    WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV,

    WA_COLNO(2) TYPE N,

    WA_FLNAME(5) TYPE C,

    L_LT TYPE SLIS_LAYOUT_ALV.

    ********************************************************************

    • GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)

    ********************************************************************

    DATA : IG_MARA_MAKT TYPE STANDARD TABLE OF TP_MARA_MAKT,

    WG_MARA_MAKT TYPE TP_MARA_MAKT.

    DATA : IG_T002 TYPE STANDARD TABLE OF TP_T002,

    WG_T002 TYPE TP_T002.

    DATA : IG_FINAL TYPE STANDARD TABLE OF TP_FINAL,

    WG_FINAL TYPE TP_FINAL.

    data : IG_MATNR TYPE STANDARD TABLE OF TP_MATNR WITH HEADER LINE,

    WG_MATNR TYPE TP_MATNR.

    DATA:BEGIN OF IG_THEAD OCCURS 0.

    INCLUDE STRUCTURE THEAD .

    DATA: END OF IG_THEAD.

    DATA:BEGIN OF IG_TLINE OCCURS 0.

    INCLUDE STRUCTURE TLINE .

    DATA:END OF IG_TLINE.

    ********************************************************************

    • FIELD-SYMBOLS

    ********************************************************************

    FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,"Dynamic internal

    "tablename

    <FS_DYNTABLE>, "Field symbol to create work area

    <FS_FLDVAL> TYPE ANY. " Field symbol to assign values

    *----


    COMPULSORY

    FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,

    <FS_DATA1> TYPE REF TO DATA,

    <FS_2> TYPE STANDARD TABLE,

    <FS_22> TYPE STANDARD TABLE,

    <FS_1>,

    <FS_11>,

    <F>,

    <FA>,

    <LWA_LINE_WA>,

    <LWA_LINE_WA1>.

    ************************************************************************

    • ------- Create Dyn Table From FC

    ************************************************************************

    DATA: LT_DATA TYPE REF TO DATA,

    LT_DATA1 TYPE REF TO DATA,

    LWA_LINE TYPE REF TO DATA,

    LWA_LINE1 TYPE REF TO DATA,

    LI_FIELD_CAT TYPE LVC_T_FCAT,

    LWA_FIELD_CAT TYPE LVC_S_FCAT.

    ********************************************************************

    • PARAMETERS & SELECT-OPTIONS

    ********************************************************************

    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    SELECT-OPTIONS : S_SPRAS FOR MAKT-SPRAS NO INTERVALS DEFAULT 'EN'

    OBLIGATORY ,

    S_MATNR FOR MARA-MATNR,

    S_MTART FOR MARA-MTART.

    PARAMETERS: GP_SIZE TYPE I DEFAULT '200'.

    SELECTION-SCREEN : END OF BLOCK B1.

    ********************************************************************

    • INITIALIZATION

    ********************************************************************

    INITIALIZATION.

    gv_repid = sy-repid.

    gv_date = sy-datum.

    ************************************************************************

    • AT SELECTION-SCREEN

    ************************************************************************

    AT SELECTION-SCREEN.

    IF GP_SIZE < 0.

    • MESSAGE E002(00).

    ENDIF.

    IF GP_SIZE > 50000.

    • MESSAGE W130(26) WITH TEXT-004.

    SET CURSOR FIELD 'gp_size'.

    ENDIF.

    ************************************************************************

    • START-OF-SELECTION

    ************************************************************************

    START-OF-SELECTION.

    PERFORM FIELDCAT.

    PERFORM LAYOUT.

    PERFORM DATA_FETCH.

    PERFORM READ_DATA_TO_FINAL.

    SORT ig_final BY matnr spras.

    gv_lin = gv_li.

    gv_li = gv_li - 2.

    LOOP AT ig_final INTO wg_final.

    ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'Material Number'.

    ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'Authorization Group'.

    g_VAR11 = wg_final-srno + 2.

    gv_li1 = gv_li1 + 2.

    MOVE : g_var11 TO gv_i1.

    ASSIGN COMPONENT g_var11 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'MatDesc'.

    g_var2 = g_var11 + gv_lines.

    ASSIGN COMPONENT g_var2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'BasicData'.

    APPEND <LWA_LINE_WA1> TO <FS_22>.

    EXIT.

    ENDLOOP.

    LOOP AT ig_final INTO wg_final.

    AT NEW matnr.

    gv_index = sy-tabix.

    ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-matnr.

    ENDAT.

    AT NEW MATNR.

    GV_INDEX = SY-TABIX.

    ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-matnr.

    ENDAT.

    ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-begru.

    ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-begru.

    gv_var = wg_final-srno + 2.

    gv_li = gv_li + 2.

    MOVE : gv_var TO gv_i.

    ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-maktx.

    ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-maktx.

    gv_var1 = gv_var + gv_lines .

    ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-ltxt.

    ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-ltxt.

    AT END OF matnr.

    APPEND <LWA_LINE_WA> TO <FS_2>.

    CLEAR <LWA_LINE_WA>.

    ENDAT.

    AT END OF matnr.

    APPEND <LWA_LINE_WA1> TO <FS_22>.

    CLEAR <LWA_LINE_WA1>.

    ENDAT.

    ENDLOOP.

    PERFORM display..

    &----


    *& Form data_fetch

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DATA_FETCH .

    SELECT matnr

    from mara up to gp_size rows

    appending corresponding fields of table ig_matnr

    where matnr in s_matnr

    and mtart in s_mtart.

    loop at ig_matnr.

    SELECT MARA~MATNR

    MARA~BEGRU

    MARA~MTART

    MAKT~SPRAS

    MAKT~MAKTX FROM MARA INNER JOIN MAKT

    ON MARAMATNR = MAKTMATNR

    appending corresponding fields of TABLE ig_mara_makt UP TO GP_SIZE

    ROWS

    WHERE makt~spras IN s_spras

    AND mara~matnr IN s_matnr

    AND mara~mtart IN s_mtart

    AND mara~matnr EQ ig_matnr-matnr.

    endloop.

    IF sy-subrc = 0.

    SORT ig_mara_makt.

    ENDIF.

    ENDFORM. " data_fetch

    &----


    *& Form read_data_to_final

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM READ_DATA_TO_FINAL .

    LOOP AT ig_mara_makt INTO wg_mara_makt .

    wg_final-MATNR = wg_mara_makt-MATNR.

    wg_final-BEGRU = wg_mara_makt-BEGRU.

    wg_final-MTART = wg_mara_makt-MTART.

    wg_final-SPRAS = wg_mara_makt-SPRAS.

    wg_final-MAKTX = wg_mara_makt-MAKTX.

    READ TABLE ig_t002 INTO wg_t002 WITH KEY spras = wg_final-spras.

    IF sy-subrc = 0.

    wg_final-srno = wg_t002-srno.

    ENDIF.

    CLEAR ig_thead[].

    ig_thead-TDOBJECT = 'MATERIAL'.

    ig_thead-TDNAME = wg_final-matnr.

    ig_thead-TDID = 'GRUN'.

    ig_thead-TDSPRAS = wg_final-spras.

    CALL FUNCTION 'TEXT_READ'

    EXPORTING

    I_HEADER = IG_THEAD

    I_READONLY = 'X'

    IMPORTING

    E_HEADER = IG_THEAD

    TABLES

    T_LINES = IG_TLINE[]

    EXCEPTIONS

    NOTFOUND = 1.

    IF sy-subrc EQ 0.

    LOOP AT ig_tline.

    gv_strg = ig_tline-tdline.

    IF gv_strg1 <> ' '.

    CONCATENATE gv_strg1 ';' gv_strg INTO gv_strg1.

    ELSE.

    gv_strg1 = gv_strg.

    ENDIF.

    ENDLOOP.

    wg_final-ltxt = gv_strg1.

    APPEND wg_final TO ig_final.

    CLEAR wg_final.

    gv_strg1 = ' '.

    ELSE.

    APPEND wg_final TO ig_final.

    ENDIF.

    ENDLOOP.

    ENDFORM. " read_data_to_final

    " read_data_to_final

    &----


    *& Form layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM LAYOUT .

    CLEAR L_LT.

    L_LT-ZEBRA = 'X'.

    L_LT-COLWIDTH_OPTIMIZE = 'X'.

    L_LT-WINDOW_TITLEBAR = 'MATERIAL DETAILS'.

    ENDFORM. " layout

    &----


    *& Form fieldcat

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FIELDCAT .

    SELECT SPRAS

    LAISO FROM t002 INTO CORRESPONDING FIELDS OF TABLE ig_t002

    WHERE spras IN s_spras.

    DESCRIBE TABLE ig_t002 LINES gv_lines.

    LOOP AT ig_t002 INTO wg_t002.

    g_v = g_v + 1.

    Wg_t002-srno = g_v.

    MODIFY ig_t002 FROM wg_t002 TRANSPORTING SRNO.

    ENDLOOP.

    LOOP AT ig_t002 INTO wg_t002.

    CLEAR WA_IT_FLDCAT.

    MOVE SY-INDEX TO WA_COLNO.

    CONCATENATE 'MD-' wg_t002-LAISO

    WA_COLNO

    INTO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = WA_FLNAME.

    WA_IT_FLDCAT-INTLEN = 250.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    APPEND WA_IT_FLDCAT TO T_FLDCAT.

    CLEAR wg_t002.

    ENDLOOP.

    LOOP AT ig_t002 INTO wg_t002.

    CLEAR WA_IT_FLDCAT.

    MOVE SY-INDEX TO WA_COLNO.

    CONCATENATE 'BD-' wg_t002-LAISO

    WA_COLNO

    INTO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = WA_FLNAME.

    WA_IT_FLDCAT-INTLEN = 250.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    APPEND WA_IT_FLDCAT TO T_FLDCAT.

    CLEAR wg_t002.

    ENDLOOP.

    MOVE 'MATNR' TO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = 'Material No'.

    WA_IT_FLDCAT-INTLEN = 18.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 1.

    MOVE 'BEGRU' TO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = 'Authorization Group'.

    WA_IT_FLDCAT-INTLEN = 4.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 2.

    DESCRIBE TABLE T_FLDCAT LINES gv_li.

    ASSIGN LT_DATA TO <FS_DATA>.

    • Creating the Dynamic Internal Table

    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

    EXPORTING

    IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue

    IMPORTING

    EP_TABLE = <FS_DATA> " Dynamic Internal Table

    EXCEPTIONS

    GENERATE_SUBPOOL_DIR_FULL = 1

    OTHERS = 2.

    • Assign Dyn Table To Field Sumbol

    ASSIGN <FS_DATA>->* TO <FS_1>.

    • Assigning the Internal Table TYPE ANY to Standard internal Table

    ASSIGN <FS_1> TO <FS_2>.

    • Creating a Workarea

    CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .

    • Assigning the Content to the workares as a Pointer

    ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.

    LOOP AT T_FLDCAT INTO WA_IT_FLDCAT.

    WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.

    WA_IT_FLDCAT1-TABNAME = WA_IT_FLDCAT-TABNAME.

    WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-SELTEXT.

    • WA_IT_FLDCAT1-REF_TABNAME = 'MARC'.

    APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.

    CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.

    ENDLOOP.

    ASSIGN LT_DATA1 TO <FS_DATA1>.

    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

    EXPORTING

    IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue

    IMPORTING

    EP_TABLE = <FS_DATA1> " Dynamic Internal table

    EXCEPTIONS

    GENERATE_SUBPOOL_DIR_FULL = 1

    OTHERS = 2.

    • Assign Dyn Table To Field Sumbol

    ASSIGN <FS_DATA1>->* TO <FS_11>.

    • Assigning the Internal Table TYPE ANY to Standard internal Table

    ASSIGN <FS_11> TO <FS_22>.

    • Creating a Workarea

    CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .

    • Assigning the Content to the workares as a Pointer

    ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.

    ENDFORM. " fieldcat

    &----


    *& Form show

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM Display .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = GV_REPID

    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    IS_LAYOUT = L_LT

    IT_FIELDCAT = T_FLDCAT1[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    • IT_EVENTS =

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = <FS_2>

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • OTHERS = 2

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM. " display

    *&----


    *&----


    FORM PF_STATUS_SET USING RS_EXTAB TYPE SLIS_T_EXTAB.

    SET PF-STATUS 'DISPLAY' .

    ENDFORM. "PF_STATUS_SET

    *&----


    *& Form Name: user_command *

    *& Form Desc: For Handling USER_COMMAND *

    *&----


    FORM USER_COMMAND USING IF_UCOMM TYPE SY-UCOMM

    IS_SELFIELD TYPE SLIS_SELFIELD.

    CASE IF_UCOMM.

    WHEN 'DOWNLOAD'.

    CALL FUNCTION 'POPUP_TO_CONFIRM'

    EXPORTING

    • TITLEBAR = ' '

    • DIAGNOSE_OBJECT = ' '

    TEXT_QUESTION = 'Data download to excel'

    • TEXT_BUTTON_1 = 'Ja'(001)

    • ICON_BUTTON_1 = ' '

    • TEXT_BUTTON_2 = 'Nein'(002)

    • ICON_BUTTON_2 = ' '

    • DEFAULT_BUTTON = '1'

    • DISPLAY_CANCEL_BUTTON = 'X'

    • USERDEFINED_F1_HELP = ' '

    • START_COLUMN = 25

    • START_ROW = 6

    • POPUP_TYPE =

    • IMPORTING

    • ANSWER =

    • TABLES

    • PARAMETER =

    • EXCEPTIONS

    • TEXT_NOT_FOUND = 1

    • OTHERS = 2

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    FILENAME = 'C:\Material-Text.xls'

    FILETYPE = 'ASC'

    • APPEND = ' '

    WRITE_FIELD_SEPARATOR = 'X'

    • HEADER = '00'

    TRUNC_TRAILING_BLANKS = 'X'

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    DAT_MODE = 'X'

    IMPORTING

    FILELENGTH = GL_LENGHT

    TABLES

    DATA_TAB = <FS_22>

    • EXCEPTIONS

    • FILE_WRITE_ERROR = 1

    • NO_BATCH = 2

    • GUI_REFUSE_FILETRANSFER = 3

    • INVALID_TYPE = 4

    • NO_AUTHORITY = 5

    • UNKNOWN_ERROR = 6

    • HEADER_NOT_ALLOWED = 7

    • SEPARATOR_NOT_ALLOWED = 8

    • FILESIZE_NOT_ALLOWED = 9

    • HEADER_TOO_LONG = 10

    • DP_ERROR_CREATE = 11

    • DP_ERROR_SEND = 12

    • DP_ERROR_WRITE = 13

    • UNKNOWN_DP_ERROR = 14

    • ACCESS_DENIED = 15

    • DP_OUT_OF_MEMORY = 16

    • DISK_FULL = 17

    • DP_TIMEOUT = 18

    • FILE_NOT_FOUND = 19

    • DATAPROVIDER_EXCEPTION = 20

    • CONTROL_FLUSH_ERROR = 21

    • OTHERS = 22

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    IF GL_LENGHT NE 0.

    MESSAGE S398(00) WITH 'DATA downloaded to EXCEL'.

    ENDIF.

    Thanks

    ENDCASE.

    ENDFORM. "user_command

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 30, 2008 at 05:50 AM

    Hi ,

    Go through this,

    REPORT yusmm_text1 NO STANDARD PAGE HEADING

    LINE-SIZE 199.

    ************************************************************************

    • T A B L E S

    ************************************************************************

    TABLES: MARA,

    MAKT,

    THEAD.

    ********************************************************************

    • GLOBAL TYPE-POOLS

    ********************************************************************

    TYPE-POOLS : SLIS.

    ********************************************************************

    • GLOBAL TYPES

    ********************************************************************

    TYPES : BEGIN OF TP_FINAL,

    MATNR TYPE MARA-MATNR,

    BEGRU TYPE MARA-BEGRU,

    MTART TYPE MARA-MTART,

    MAKTX TYPE MAKT-MAKTX,

    SPRAS TYPE MAKT-SPRAS,

    LTXT(2000) TYPE C ,

    SRNO TYPE N ,

    END OF TP_FINAL.

    TYPES : BEGIN OF TP_T002,

    SPRAS TYPE T002-SPRAS,

    LAISO TYPE T002-LAISO,

    SRNO TYPE N ,

    END OF TP_T002.

    TYPES : BEGIN OF TP_MARA_MAKT,

    MATNR TYPE MARA-MATNR,

    BEGRU TYPE MARA-BEGRU,

    MTART TYPE MARA-MTART,

    SPRAS TYPE MAKT-SPRAS,

    MAKTX TYPE MAKT-MAKTX,

    END OF TP_MARA_MAKT.

    Types: BEGIN OF tp_matnr,

    matnr TYPE mara-matnr,

    END OF tp_matnr.

    • ********************************************************************

    • GLOBAL ELEMENTARY VARIABLES

    *

    *********************************************************************

    DATA : gv_date TYPE sy-datum.

    DATA : gv_repid TYPE sy-repid.

    DATA : g_var1(10) TYPE C.

    DATA : gv_index TYPE sy-tabix.

    DATA: gv_strg TYPE string,

    gv_strg1(2000) TYPE C.

    DATA : gv_lang TYPE sy-langu.

    DATA : g_v(3) TYPE N .

    DATA : gv_lines(3) TYPE N .

    DATA : gv_var(3) TYPE N .

    DATA : gv_var1(3) TYPE N.

    DATA: gv_str TYPE STRING.

    DATA: gv_str1 TYPE STRING.

    DATA : gv_li TYPE I,

    gv_lit TYPE I,

    gv_lin TYPE I.

    DATA: g_var11(3) TYPE N,

    gv_li1(3) TYPE N,

    g_var2(3) TYPE N.

    DATA : gv_i1 TYPE I.

    DATA : gv_i TYPE I.

    DATA: gl_lenght TYPE I.

    *********************************************************************

    • GLOBAL STRUCTURES

    ******************************************************

    DATA: T_NEWTABLE TYPE REF TO DATA,

    T_NEWLINE TYPE REF TO DATA,

    T_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

    T_FLDCAT TYPE LVC_T_FCAT,

    WA_IT_FLDCAT TYPE LVC_S_FCAT,

    WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV,

    WA_COLNO(2) TYPE N,

    WA_FLNAME(5) TYPE C,

    L_LT TYPE SLIS_LAYOUT_ALV.

    ********************************************************************

    • GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)

    ********************************************************************

    DATA : IG_MARA_MAKT TYPE STANDARD TABLE OF TP_MARA_MAKT,

    WG_MARA_MAKT TYPE TP_MARA_MAKT.

    DATA : IG_T002 TYPE STANDARD TABLE OF TP_T002,

    WG_T002 TYPE TP_T002.

    DATA : IG_FINAL TYPE STANDARD TABLE OF TP_FINAL,

    WG_FINAL TYPE TP_FINAL.

    data : IG_MATNR TYPE STANDARD TABLE OF TP_MATNR WITH HEADER LINE,

    WG_MATNR TYPE TP_MATNR.

    DATA:BEGIN OF IG_THEAD OCCURS 0.

    INCLUDE STRUCTURE THEAD .

    DATA: END OF IG_THEAD.

    DATA:BEGIN OF IG_TLINE OCCURS 0.

    INCLUDE STRUCTURE TLINE .

    DATA:END OF IG_TLINE.

    ********************************************************************

    • FIELD-SYMBOLS

    ********************************************************************

    FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,"Dynamic internal

    "tablename

    <FS_DYNTABLE>, "Field symbol to create work area

    <FS_FLDVAL> TYPE ANY. " Field symbol to assign values

    *----


    COMPULSORY

    FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,

    <FS_DATA1> TYPE REF TO DATA,

    <FS_2> TYPE STANDARD TABLE,

    <FS_22> TYPE STANDARD TABLE,

    <FS_1>,

    <FS_11>,

    <F>,

    <FA>,

    <LWA_LINE_WA>,

    <LWA_LINE_WA1>.

    ************************************************************************

    • ------- Create Dyn Table From FC

    ************************************************************************

    DATA: LT_DATA TYPE REF TO DATA,

    LT_DATA1 TYPE REF TO DATA,

    LWA_LINE TYPE REF TO DATA,

    LWA_LINE1 TYPE REF TO DATA,

    LI_FIELD_CAT TYPE LVC_T_FCAT,

    LWA_FIELD_CAT TYPE LVC_S_FCAT.

    ********************************************************************

    • PARAMETERS & SELECT-OPTIONS

    ********************************************************************

    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    SELECT-OPTIONS : S_SPRAS FOR MAKT-SPRAS NO INTERVALS DEFAULT 'EN'

    OBLIGATORY ,

    S_MATNR FOR MARA-MATNR,

    S_MTART FOR MARA-MTART.

    PARAMETERS: GP_SIZE TYPE I DEFAULT '200'.

    SELECTION-SCREEN : END OF BLOCK B1.

    ********************************************************************

    • INITIALIZATION

    ********************************************************************

    INITIALIZATION.

    gv_repid = sy-repid.

    gv_date = sy-datum.

    ************************************************************************

    • AT SELECTION-SCREEN

    ************************************************************************

    AT SELECTION-SCREEN.

    IF GP_SIZE < 0.

    • MESSAGE E002(00).

    ENDIF.

    IF GP_SIZE > 50000.

    • MESSAGE W130(26) WITH TEXT-004.

    SET CURSOR FIELD 'gp_size'.

    ENDIF.

    ************************************************************************

    • START-OF-SELECTION

    ************************************************************************

    START-OF-SELECTION.

    PERFORM FIELDCAT.

    PERFORM LAYOUT.

    PERFORM DATA_FETCH.

    PERFORM READ_DATA_TO_FINAL.

    SORT ig_final BY matnr spras.

    gv_lin = gv_li.

    gv_li = gv_li - 2.

    LOOP AT ig_final INTO wg_final.

    ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'Material Number'.

    ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'Authorization Group'.

    g_VAR11 = wg_final-srno + 2.

    gv_li1 = gv_li1 + 2.

    MOVE : g_var11 TO gv_i1.

    ASSIGN COMPONENT g_var11 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'MatDesc'.

    g_var2 = g_var11 + gv_lines.

    ASSIGN COMPONENT g_var2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = 'BasicData'.

    APPEND <LWA_LINE_WA1> TO <FS_22>.

    EXIT.

    ENDLOOP.

    LOOP AT ig_final INTO wg_final.

    AT NEW matnr.

    gv_index = sy-tabix.

    ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-matnr.

    ENDAT.

    AT NEW MATNR.

    GV_INDEX = SY-TABIX.

    ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-matnr.

    ENDAT.

    ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-begru.

    ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-begru.

    gv_var = wg_final-srno + 2.

    gv_li = gv_li + 2.

    MOVE : gv_var TO gv_i.

    ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-maktx.

    ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-maktx.

    gv_var1 = gv_var + gv_lines .

    ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA> TO <F>.

    <F> = wg_final-ltxt.

    ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.

    <FA> = wg_final-ltxt.

    AT END OF matnr.

    APPEND <LWA_LINE_WA> TO <FS_2>.

    CLEAR <LWA_LINE_WA>.

    ENDAT.

    AT END OF matnr.

    APPEND <LWA_LINE_WA1> TO <FS_22>.

    CLEAR <LWA_LINE_WA1>.

    ENDAT.

    ENDLOOP.

    PERFORM display..

    &----


    *& Form data_fetch

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DATA_FETCH .

    SELECT matnr

    from mara up to gp_size rows

    appending corresponding fields of table ig_matnr

    where matnr in s_matnr

    and mtart in s_mtart.

    loop at ig_matnr.

    SELECT MARA~MATNR

    MARA~BEGRU

    MARA~MTART

    MAKT~SPRAS

    MAKT~MAKTX FROM MARA INNER JOIN MAKT

    ON MARAMATNR = MAKTMATNR

    appending corresponding fields of TABLE ig_mara_makt UP TO GP_SIZE

    ROWS

    WHERE makt~spras IN s_spras

    AND mara~matnr IN s_matnr

    AND mara~mtart IN s_mtart

    AND mara~matnr EQ ig_matnr-matnr.

    endloop.

    IF sy-subrc = 0.

    SORT ig_mara_makt.

    ENDIF.

    ENDFORM. " data_fetch

    &----


    *& Form read_data_to_final

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM READ_DATA_TO_FINAL .

    LOOP AT ig_mara_makt INTO wg_mara_makt .

    wg_final-MATNR = wg_mara_makt-MATNR.

    wg_final-BEGRU = wg_mara_makt-BEGRU.

    wg_final-MTART = wg_mara_makt-MTART.

    wg_final-SPRAS = wg_mara_makt-SPRAS.

    wg_final-MAKTX = wg_mara_makt-MAKTX.

    READ TABLE ig_t002 INTO wg_t002 WITH KEY spras = wg_final-spras.

    IF sy-subrc = 0.

    wg_final-srno = wg_t002-srno.

    ENDIF.

    CLEAR ig_thead[].

    ig_thead-TDOBJECT = 'MATERIAL'.

    ig_thead-TDNAME = wg_final-matnr.

    ig_thead-TDID = 'GRUN'.

    ig_thead-TDSPRAS = wg_final-spras.

    CALL FUNCTION 'TEXT_READ'

    EXPORTING

    I_HEADER = IG_THEAD

    I_READONLY = 'X'

    IMPORTING

    E_HEADER = IG_THEAD

    TABLES

    T_LINES = IG_TLINE[]

    EXCEPTIONS

    NOTFOUND = 1.

    IF sy-subrc EQ 0.

    LOOP AT ig_tline.

    gv_strg = ig_tline-tdline.

    IF gv_strg1 <> ' '.

    CONCATENATE gv_strg1 ';' gv_strg INTO gv_strg1.

    ELSE.

    gv_strg1 = gv_strg.

    ENDIF.

    ENDLOOP.

    wg_final-ltxt = gv_strg1.

    APPEND wg_final TO ig_final.

    CLEAR wg_final.

    gv_strg1 = ' '.

    ELSE.

    APPEND wg_final TO ig_final.

    ENDIF.

    ENDLOOP.

    ENDFORM. " read_data_to_final

    " read_data_to_final

    &----


    *& Form layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM LAYOUT .

    CLEAR L_LT.

    L_LT-ZEBRA = 'X'.

    L_LT-COLWIDTH_OPTIMIZE = 'X'.

    L_LT-WINDOW_TITLEBAR = 'MATERIAL DETAILS'.

    ENDFORM. " layout

    &----


    *& Form fieldcat

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FIELDCAT .

    SELECT SPRAS

    LAISO FROM t002 INTO CORRESPONDING FIELDS OF TABLE ig_t002

    WHERE spras IN s_spras.

    DESCRIBE TABLE ig_t002 LINES gv_lines.

    LOOP AT ig_t002 INTO wg_t002.

    g_v = g_v + 1.

    Wg_t002-srno = g_v.

    MODIFY ig_t002 FROM wg_t002 TRANSPORTING SRNO.

    ENDLOOP.

    LOOP AT ig_t002 INTO wg_t002.

    CLEAR WA_IT_FLDCAT.

    MOVE SY-INDEX TO WA_COLNO.

    CONCATENATE 'MD-' wg_t002-LAISO

    WA_COLNO

    INTO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = WA_FLNAME.

    WA_IT_FLDCAT-INTLEN = 250.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    APPEND WA_IT_FLDCAT TO T_FLDCAT.

    CLEAR wg_t002.

    ENDLOOP.

    LOOP AT ig_t002 INTO wg_t002.

    CLEAR WA_IT_FLDCAT.

    MOVE SY-INDEX TO WA_COLNO.

    CONCATENATE 'BD-' wg_t002-LAISO

    WA_COLNO

    INTO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = WA_FLNAME.

    WA_IT_FLDCAT-INTLEN = 250.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    APPEND WA_IT_FLDCAT TO T_FLDCAT.

    CLEAR wg_t002.

    ENDLOOP.

    MOVE 'MATNR' TO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = 'Material No'.

    WA_IT_FLDCAT-INTLEN = 18.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 1.

    MOVE 'BEGRU' TO WA_FLNAME.

    WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.

    WA_IT_FLDCAT-DATATYPE = 'CHAR'.

    WA_IT_FLDCAT-SELTEXT = 'Authorization Group'.

    WA_IT_FLDCAT-INTLEN = 4.

    WA_IT_FLDCAT-TABNAME = '<FS_2>'.

    INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 2.

    DESCRIBE TABLE T_FLDCAT LINES gv_li.

    ASSIGN LT_DATA TO <FS_DATA>.

    • Creating the Dynamic Internal Table

    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

    EXPORTING

    IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue

    IMPORTING

    EP_TABLE = <FS_DATA> " Dynamic Internal Table

    EXCEPTIONS

    GENERATE_SUBPOOL_DIR_FULL = 1

    OTHERS = 2.

    • Assign Dyn Table To Field Sumbol

    ASSIGN <FS_DATA>->* TO <FS_1>.

    • Assigning the Internal Table TYPE ANY to Standard internal Table

    ASSIGN <FS_1> TO <FS_2>.

    • Creating a Workarea

    CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .

    • Assigning the Content to the workares as a Pointer

    ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.

    LOOP AT T_FLDCAT INTO WA_IT_FLDCAT.

    WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.

    WA_IT_FLDCAT1-TABNAME = WA_IT_FLDCAT-TABNAME.

    WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-SELTEXT.

    • WA_IT_FLDCAT1-REF_TABNAME = 'MARC'.

    APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.

    CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.

    ENDLOOP.

    ASSIGN LT_DATA1 TO <FS_DATA1>.

    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

    EXPORTING

    IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue

    IMPORTING

    EP_TABLE = <FS_DATA1> " Dynamic Internal table

    EXCEPTIONS

    GENERATE_SUBPOOL_DIR_FULL = 1

    OTHERS = 2.

    • Assign Dyn Table To Field Sumbol

    ASSIGN <FS_DATA1>->* TO <FS_11>.

    • Assigning the Internal Table TYPE ANY to Standard internal Table

    ASSIGN <FS_11> TO <FS_22>.

    • Creating a Workarea

    CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .

    • Assigning the Content to the workares as a Pointer

    ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.

    ENDFORM. " fieldcat

    &----


    *& Form show

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM Display .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = GV_REPID

    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    IS_LAYOUT = L_LT

    IT_FIELDCAT = T_FLDCAT1[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    • IT_EVENTS =

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = <FS_2>

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

    • OTHERS = 2

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ENDFORM. " display

    *&----


    *&----


    FORM PF_STATUS_SET USING RS_EXTAB TYPE SLIS_T_EXTAB.

    SET PF-STATUS 'DISPLAY' .

    ENDFORM. "PF_STATUS_SET

    *&----


    *& Form Name: user_command *

    *& Form Desc: For Handling USER_COMMAND *

    *&----


    FORM USER_COMMAND USING IF_UCOMM TYPE SY-UCOMM

    IS_SELFIELD TYPE SLIS_SELFIELD.

    CASE IF_UCOMM.

    WHEN 'DOWNLOAD'.

    CALL FUNCTION 'POPUP_TO_CONFIRM'

    EXPORTING

    • TITLEBAR = ' '

    • DIAGNOSE_OBJECT = ' '

    TEXT_QUESTION = 'Data download to excel'

    • TEXT_BUTTON_1 = 'Ja'(001)

    • ICON_BUTTON_1 = ' '

    • TEXT_BUTTON_2 = 'Nein'(002)

    • ICON_BUTTON_2 = ' '

    • DEFAULT_BUTTON = '1'

    • DISPLAY_CANCEL_BUTTON = 'X'

    • USERDEFINED_F1_HELP = ' '

    • START_COLUMN = 25

    • START_ROW = 6

    • POPUP_TYPE =

    • IMPORTING

    • ANSWER =

    • TABLES

    • PARAMETER =

    • EXCEPTIONS

    • TEXT_NOT_FOUND = 1

    • OTHERS = 2

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    FILENAME = 'C:\Material-Text.xls'

    FILETYPE = 'ASC'

    • APPEND = ' '

    WRITE_FIELD_SEPARATOR = 'X'

    • HEADER = '00'

    TRUNC_TRAILING_BLANKS = 'X'

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    DAT_MODE = 'X'

    IMPORTING

    FILELENGTH = GL_LENGHT

    TABLES

    DATA_TAB = <FS_22>

    • EXCEPTIONS

    • FILE_WRITE_ERROR = 1

    • NO_BATCH = 2

    • GUI_REFUSE_FILETRANSFER = 3

    • INVALID_TYPE = 4

    • NO_AUTHORITY = 5

    • UNKNOWN_ERROR = 6

    • HEADER_NOT_ALLOWED = 7

    • SEPARATOR_NOT_ALLOWED = 8

    • FILESIZE_NOT_ALLOWED = 9

    • HEADER_TOO_LONG = 10

    • DP_ERROR_CREATE = 11

    • DP_ERROR_SEND = 12

    • DP_ERROR_WRITE = 13

    • UNKNOWN_DP_ERROR = 14

    • ACCESS_DENIED = 15

    • DP_OUT_OF_MEMORY = 16

    • DISK_FULL = 17

    • DP_TIMEOUT = 18

    • FILE_NOT_FOUND = 19

    • DATAPROVIDER_EXCEPTION = 20

    • CONTROL_FLUSH_ERROR = 21

    • OTHERS = 22

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    IF GL_LENGHT NE 0.

    MESSAGE S398(00) WITH 'DATA downloaded to EXCEL'.

    ENDIF.

    ENDCASE.

    ENDFORM. "user_command

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.