Error in FM :Alsm_Excel_to_Internal_Table

Hi Everyone,
         I Tried to Upload Excel File to internal table using FM:Alsm_excel_to_internal_table._I am getting  error like UPLOAD_OLE  .
Any one Help me  why that error is occurring and how to solve it.  
Thanks in Advance

Hi Santosh,
You are getting this error due to improper file name given. Use this function module to get the name of file to be uploaded by F4.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
   EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = 'P_PATH'
*     STATIC              = ' '
*     MASK                = ' '
    CHANGING
      FILE_NAME           = P_PATH
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
Where P_PATH is: the filename.
PARAMETERS:
  P_PATH   TYPE  RLGRAP-FILENAME MODIF ID A2.
Regards,
Amit.

Similar Messages

  • Error while using ALSM_EXCEL_TO_INTERNAL_TABLE

    I am getting the exception  "Upload OLE" while using this FM to upload data from excel sheet into SAP system. It errors out at the following statement inside the FM -
    CREATE OBJECT obj_application 'Excel.Application'.
    Any pointers?
    Regards,
    Shivali

    hi, take a look at this code
    *& Report  ZKRIS_OLE3_PALETTE
    *& Displays the full OLE color range in excel
    REPORT  ZKRIS_OLE3_PALETTE.
    TYPE-POOLS ole2 .
    DATA:  count TYPE i,
           count_real TYPE i,
           application TYPE ole2_object,
           workbook TYPE ole2_object,
           excel     TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256. " change to 16384 for excel 2007
    DATA index TYPE i.
    DATA:
          h_cell        TYPE ole2_object,        " cell
          h_f           TYPE ole2_object,        " font
          h_int         TYPE ole2_object,
          h_width       TYPE ole2_object,
          h_columns     TYPE ole2_object,
          h_rows        TYPE ole2_object,
          h_font        TYPE ole2_object,
          h_entirecol   TYPE ole2_object.
    DATA: h_range       TYPE ole2_object.
    DATA: h_merge       TYPE ole2_object.
    CREATE OBJECT excel 'EXCEL.APPLICATION'.
    IF sy-subrc NE 0.
      WRITE: / 'No EXCEL creation possible'.
      STOP.
    ENDIF.
    SET PROPERTY OF excel 'DisplayAlerts' = 0.
    CALL METHOD OF excel 'WORKBOOKS' = workbook .
    SET PROPERTY OF excel 'VISIBLE' = 1.
    creating workbook
    SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
    CALL METHOD OF workbook 'ADD'.
    CALL METHOD OF excel 'WORKSHEETS' = sheet
      EXPORTING
        #1 = 1.
    SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
    CALL METHOD OF sheet 'ACTIVATE'.
    DATA: col TYPE i VALUE 1,
    row TYPE i VALUE 2,
    col1 TYPE i VALUE 2,
    col_real TYPE i VALUE 1.
    row = 1.
    col = 3.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'No.'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '2:2'.
    SET PROPERTY OF h_rows 'WrapText' = 1.
    col = 9.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'No.'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
    SET PROPERTY OF h_cell 'Bold' = 1.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '1:1'.
    SET PROPERTY OF h_rows 'WrapText' = 1.
    GET PROPERTY OF h_rows 'Font' = h_font.
    SET PROPERTY OF h_font 'Bold' = 1.
    count = 1.
    count_real = count.
    row = 2.
    col = 3.
    DO 56 TIMES.
      PERFORM write_num_and_color.
    ENDDO.
    autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'C:L'.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    SET PROPERTY OF h_entirecol 'Autofit' = 1.
    write palette on lhs
    *range
    CALL METHOD OF excel 'Range' = h_range
      EXPORTING
        #1 = 'A2'
        #2 = 'A20'.
    CALL METHOD OF h_range 'Merge' = h_merge .
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = 2
        #2 = 1.
    SET PROPERTY OF h_cell 'Value' = 'Palette'.
    SET PROPERTY OF h_cell 'Orientation' = 90.         "angled.
    SET PROPERTY OF h_cell 'HorizontalAlignment' = 3.  "center align
    GET PROPERTY OF h_cell 'Font'    = h_f.
    SET PROPERTY OF h_f 'Bold' = 1.                    "bold
    SET PROPERTY OF h_f 'Name' = 'Comic Sans MS'.
    SET PROPERTY OF h_f 'Size' = '14'.
    SET PROPERTY OF h_cell 'VerticalAlignment' = 2.  "center align
    autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'A:A'.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    SET PROPERTY OF h_columns 'ColumnWidth' = 4.
    *&      Form  write_num_and_color
          text
    FORM write_num_and_color.
      index = row_max * ( row - 1 ) + col.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
      SET PROPERTY OF cells 'Value' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
      SET PROPERTY OF h_int  'ColorIndex' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
      GET PROPERTY OF h_cell 'Font'    = h_f.
      SET PROPERTY OF h_f 'ColorIndex' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
      SET PROPERTY OF h_int  'ColorIndex' = 1.
      SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
      GET PROPERTY OF h_cell 'Font'    = h_f.
      SET PROPERTY OF h_f 'ColorIndex' = count_real.
      row = row + 1.
      col = col - 3.
      count = count + 1.
      IF count = 29.
        count = 1.
        row = 2.
        col = col + 6.
      ENDIF.
      count_real = count_real + 1.
    ENDFORM.                    "write_num_and_color
    hope this helps.
    regs,
    hema.

  • ALSM_EXCEL_TO_INTERNAL_TABLE , ERROR SY-SUBRC = 2 , UPLOAD_OLE

    Hi,
    I would like to know in what cases sy-subrc is '2' in function ALSM_EXCEL_TO_INTERNAL_TABLE
    the result of this function depends the version of excel, office ???
    Somebody can help me ?

    Hi Michael,
    It is a Upload error from Excel file.
    The return value of sy-subrc is as follows in Help.SAP.com
    Return Value
    SY-SUBRC
    Return value set by the following ABAP statements. In general, a content of 0 means that the statement was executed without problems.
    ·        ASSIGN sets SY-SUBRC to 0 if assignment to field symbol is possible, otherwise 4.
    ·        ASSIGN <dref>->* sets SY-SUBRC to 0 if dereferencing is possible, otherwise 4.
    ·        AUTHORITY-CHECK sets SY-SUBRC to 0 if the user has the necessary authorization, otherwise 4, 8, 12, 16, 24, 28, 32, or 36 depending on the cause.
    ·        CALL DIALOG with USING sets SY-SUBRC to 0, if processing was successful, otherwise <>0.
    ·        CALL FUNCTION sets SY-SUBRC according to the exception handling.
    ·        CALL METHOD sets SY-SUBRC according to the exception handling.
    ·        CALL SELECTION-SCREEN sets SY-SUBRC to 0 if the user chose Enter or Execute and 4 if the user chose Cancel.
    ·        CALL TRANSACTION with USING sets SY-SUBRC to 0 if processing was successful, otherwise <>0.
    ·        CATCH SYSTEM-EXCEPTIONS sets SY-SUBRC if there are runtime errors after the ENDCATCH statement. The value is specified in the program.
    ·        COMMIT WORK sets SY-SUBRC to 0.
    ·        COMMIT WORK AND WAIT sets SY-SUBRC to 0 if update was successful, otherwise <>0.
    ·        COMMUNICATION INIT DESTINATION u2026 RETURNCODE sets SY-SUBRC as specified.
    ·        CONCATENATE sets SY-SUBRC to 0 if the result fits into target variable, otherwise 4.
    ·        CREATE OBJECT sets SY-SUBRC if the exceptions of the instance constructor are handled.
    ·        CREATE OBJECT in OLE2 sets SY-SUBRC to 0 if an external object was created, otherwise 1,2, 3 with different causes.
    ·        DELETE sets SY-SUBRC to 0 if the operation was successful, otherwise 4 or <> 0 depending on cause.
    ·        DEMAND u2026 MESSAGES INTO sets SY-SUBRC to 0 if a message table is empty, otherwise <> 0.
    ·        DESCRIBE LIST sets SY-SUBRC to 0 if row or list exists, otherwise 4 or 8.
    ·        EXEC SQL - ENDEXEC sets SY-SUBRC to 0 in almost all cases. Only if no set was read with FETCH is SY-SUBRC 4.
    ·        FETCH sets SY-SUBRC to 0 if at least one row was read, otherwise 4.
    ·         GENERATE SUBROUTINE POOL sets SY-SUBRC to 0 if generation was successful, otherwise 8.
    ·        GET CURSOR sets SY-SUBRC to 0 if the cursor is correctly positioned, otherwise 4.
    ·        GET PARAMETER sets SY-SUBRC to 0 if value found in SAP Memory, otherwise 4.
    ·        IMPORT sets SY-SUBRC to 0 if import of data objects was successful, otherwise 4.
    ·        LOAD REPORT sets SY-SUBRC to 0 if the operation was successful, otherwise 4 or 8 depending on cause.
    ·        LOOP sets SY-SUBRC to 0 if loop over extract was passed at least once, otherwise 4.
    ·        LOOP AT sets SY-SUBRC to 0 if loop over internal table was passed at least once, otherwise 4.
    ·        MODIFY sets SY-SUBRC to 0 if operation was successful, otherwise 4.
    ·        MODIFY LINE sets SY-SUBRC to 0 if list row was changed, otherwise <> 0.
    ·        MODIFY sets SY-SUBRC to 0 if operation was successful, otherwise 4.
    ·        OLE2 automation, bundled commands set SY-SUBRC to 0 if all were successfully executed, otherwise 1, 2, 3, 4 depending on cause.
    ·        OPEN DATASET sets SY-SUBRC to 0 if the file was opened, otherwise 8.
    ·        Open SQL commands set SY-SUBRC to 0 if operation was successful, otherwise <>0.
    ·        OVERLAY sets SY-SUBRC to 0 if at least one character is overlayed, otherwise 4.
    ·        READ DATASET sets SY-SUBRC to 0 if the read operation was successful, otherwise 4 or 8 depending on cause.
    ·        READ LINE sets SY-SUBRC to 0 if list row exists, otherwise <> 0.
    ·        READ TABLE sets SY-SUBRC to 0 if the table row was found, otherwise 2, 4, 8 depending on cause.
    ·        REPLACE sets SY-SUBRC to 0 if search string could be replaced, otherwise <> 0.
    ·        ROLLBACK WORK always sets SY-SUBRC to 0.
    ·        SCROLL sets SY-SUBRC to 0 if scrolling in list successful, otherwise 4 or 8 depending on cause.
    ·        SEARCH sets SY-SUBRC to 0 if search string was found, otherwise 4.
    ·        SELECT sets SY-SUBRC to 0 if at least one row was read, otherwise 4 or even 8 with SELECT SINGLE FOR UPDATE.
    ·        SET COUNTRY sets SY-SUBRC to 0 if country ID was found in table T005X, otherwise 4.
    ·        SET BIT sets SY-SUBRC to 0 if bit was set, otherwise <> 0.
    ·        SET TITLEBAR sets SY-SUBRC to 0 if title exists, otherwise 4.
    ·        SHIFT u2026 UP TO sets SY-SUBRC to 0 if position was found in character string, otherwise 4.
    ·        SPLIT sets SY-SUBRC to 0 if size of target fields is sufficient, otherwise 4.
    ·        UPDATE sets SY-SUBRC to 0 if operation successful, otherwise 4.
    ·        WRITE u2026 TO sets SY-SUBRC to 0 if assignment successful, otherwise 4.
    Thanks & Regards,
    Dileep .C

  • System  Error in ALSM_EXCEL_TO_INTERNAL_TABLE  function

    Hi everybody,
    I'm using the ALSM_EXCEL_TO_INTERNAL_TABLE  function in order to upload an excel file which contains 2,000 lines but it shows me the next error message. "SYSTEM CANNOT WRITE TABLE    function rfctr_drvset".  Anyone of you had the same problem? <removed by moderator>.
    Thnks in advance,
    Luis G.
    Edited by: Thomas Zloch on Oct 29, 2010 11:58 AM

    Hi,
    I found this link on internet http://sap.ittoolbox.com/groups/technical-functional/sap-dev/error-in-rfc-and-lower-layer-system_cannot_write_table-3644736
    hope this helps
    Best regards,
    Caíque Escaler

  • ALSM_EXCEL_TO_INTERNAL_TABLE:error:sy-subrc=2

    hi all,
        i got a problem in transfering data from excel sheet to internal table.
       it throws sy-subrc value =2.it shoes this value when reading fm pgm.
    can anyone pl help me.

    hi,
    this function module uploads data from excel to internal table,
    check this sample code and make the changes needed in your program
    TYPE-POOLS truxs.
    TABLES:zmatnr.
    DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    DATA row LIKE alsmex_tabline-row.
    data : g_matnr like mara-matnr.
    data : count type i.
    data : itab_count type i.
    data : gi_final like zmatnr occurs 0 with header line.
    *data : begin of gi_final occurs 0,
    mat_old like mara-matnr,
    mat_new like mara-matnr,
    end of gi_final.
    ************************Selection Screen**************************
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.
    select-options : records for count.
    SELECTION-SCREEN END OF BLOCK b1.
    **********************At Selection Screen**************************
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.
    PERFORM search.
    START-OF-SELECTION.
    perform process.
    form process.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    filename = pfname
    i_begin_col = 1
    i_begin_row = 2
    i_end_col = 12
    i_end_row = 65000
    TABLES
    intern = itab
    EXCEPTIONS
    inconsistent_parameters = 1
    upload_ole = 2
    OTHERS = 3.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    describe table itab lines itab_count.
    row = 1.
    loop at itab.
    if itab-row row.
    append gi_final.
    clear gi_final.
    endif.
    case itab-col.
    when '1'.
    CLEAR G_MATNR.
    gi_final-OLD_MATNR = itab-value.
    CONCATENATE 'NEW' gi_final-old_matnr INTO itab-value.
    gi_final-new_MATNR = itab-value.
    endcase.
    row = itab-row.
    endloop.
    append gi_final.
    clear gi_final.
    CALL FUNCTION 'PROGRESS_INDICATOR'
    EXPORTING
    I_TEXT = 'File Has Been Successfully Uploaded from Workstation ' .
    if not gi_final[] is initial.
    if not records-low is initial .
    if not records-high is initial.
    records-high = records-high + 1.
    DESCRIBE TABLE gi_final LINES count.
    IF records-high < count.
    DELETE gi_final FROM records-high TO count.
    ENDIF.
    IF records-low <> 1.
    IF records-low 0.
    DELETE gi_final FROM 1 TO records-low.
    ENDIF.
    ENDIF.
    endif.
    endif.
    endif.
    IF NOT GI_FINAL[] IS INITIAL.
    CALL FUNCTION 'PROGRESS_INDICATOR'
    EXPORTING
    I_TEXT = 'Processing zmatnr table'
    I_OUTPUT_IMMEDIATELY = 'X'.
    if itab_count count.
    message i000 with 'records are not matching'.
    exit.
    else.
    modify zmatnr from table gi_final.
    message i000 with 'data base table modified successfully'.
    endif.
    endif.
    endform.
    *& Form search
    text
    --> p1 text
    <-- p2 text
    FORM search .
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    static = 'X'
    CHANGING
    file_name = pfname.
    ENDFORM. " search
    Cheers,
    Chandru

  • ALSM_EXCEL_TO_INTERNAL_TABLE index error

    HI All,
    Do i have to close my Excel when using ALSM_EXCEL_TO_INTERNAL_TABLE ?
    Because some times the codes run properly but the field which is index give 000000000000000000 (NUMC 18).
    PS: i use this FM about 10 times to open 1 excel file to fetch different row and col for different tables.
    Please help.

    HI All,
    Do i have to close my Excel when using ALSM_EXCEL_TO_INTERNAL_TABLE ?
    Because some times the codes run properly but the field which is index give 000000000000000000 (NUMC 18).
    PS: i use this FM about 10 times to open 1 excel file to fetch different row and col for different tables.
    Please help.

  • Error in BAPI

    Hello ,
    While using the BAPI 'BAPI_MATERIAL_SAVEDATA', to extend material from one plant to another my code is throwing an error 'Currency initial v,current amount 6,000.0000 in MOVING_PR was transferred without a currency'
    Enter a material number'
    I have incorporated mbew-peinh, even then its throwing the same error.
    I snd copy of my code.
    report  zmm_r018 .
    *& Prog to copy n create the existing material using bapi .
    tables: t001l, "Storage Locations
            mara,  "General Material Data
            makt,  "Material Descriptions
            mbew,  "Material Valuation
            marc,  "Plant Data for Material
            mltx.  "Purchase Order Descriptions
    **parameters : new_mat like mara-matnr,
                desc like makt-maktx,
    *data:         ref_mat like mara-matnr.
    *data: xmara type mara.
    **data: wamatnr like mara-matnr.
    data: potext type string."Purchase Order Desc
    data : ihead_data type bapimathead,
           iclient_data type bapi_mara,                    "Client Data
           iclient_datax type bapi_marax,
          imakt like bapi_makt,                           "Mat Description
           iplant_data    like bapi_marc,                  "Plant View
           iplant_datax   like bapi_marcx,
           iltxt type table of bapi_mltx with header line, "Pur Order Text
           istoragelocationdata type bapi_mard,            "Storage Location
           istoragelocationdatax type bapi_mardx,
           iaccounting_data  like bapi_mbew,               "Accounting View
           iaccounting_datax  like bapi_mbewx,
           bapiret like bapiret2,
           returnm type table of bapi_matreturn2 with header line.
    **Internal Table to hold the records in the text file
    types:begin of it,
    matnr(18),  " Material number
    mbrsh(1),   " Industry sector
    mtart(4),   " Material type
    werks(4),   " Plant
    lgort_d(4),  "Storage Location
    maktx(40),  " Material description
    meins(3),   " Base unit of measure
    matkl(9) ,  " Material group
    bismt(18),  " Old Material number
    spart(2),   " Division
    gewei(3),   " Weight Unit
    text1(30),  " Purchasr Order Text
    text2(30),
    text3(30),
    text4(30),
    text5(30),
    text6(30),
    dzeinr(22), " Document
    ekgrp(3),   " Purchasing group
    ekwsl(4),   " Purchase Value Key
    webaz(3),   " Goods receipt processing time in days
    dismm(2),   " MRP Type
    minbe(13),  "Reorder point
    dispo(3),   " MRP Controller
    disls(2),   "Lot size (materials planning)
    mabst(13),  "Maximum stock level
    plifz(3),   " Planned delivery time in days
    webaz1(3),  " Goods receipt processing time in days
    fhori(3),   "Scheduling Margin Key for Floats
    eisbe(13),  "Safety stock
    mtvfp(2),   "Checking Group for Availability Check
    lgpbe(10),  "Storage Bin
    qmatauth(6),"Material Authorization Group for Activities in QM
    qmpur(1),   " QM in Procurement is Active
    qsspur(8),  "Control Key for Quality Management in Procurement
    bklas(4),   " Valuation Class
    bwtty_d(1), "Valuation Category
    vprsv(1),   " Price control indicator
    verpr_bapi(23), "Moving average price/periodic unit price
    peinh(5),     "Price Unit
    end of it.
    data: it_data type table of it,
          wa_data like line  of it_data.
    *Decalraing flag
    data: v_flag value ''.
    *DECLARING WORK AREAs  TO BE PASSED TO THE FUNCTION MODULE.
    data: bapi_head like bapimathead,
          bapi_clientdata like bapi_mara,
          bapi_clientdatax like bapi_marax,
          bapi_plantdata like bapi_marc,
          bapi_plantdatax like  bapi_marcx,
          bapi_storagelocationdata like bapi_mard,
          bapi_storagelocationdatax like bapi_mardx,
          bapi_salesdata like bapi_mvke,
          bapi_salesdatax like bapi_mvkex,
          bapi_makt like bapi_makt,
          bapi_return like bapiret2.
    *INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION
    data: begin of it_makt occurs 0.
    include structure bapi_makt.
    data end of it_makt.
    data:begin of it_ret occurs 0.
    include structure bapiret2.
    data end of it_ret.
    *INTERNAL TABLE TO HOLD HEADER DATA
    data: it_excel type alsmex_tabline occurs 0 with header line.
    *SELECTION-SCREEN ELEMENTS
    selection-screen begin of block b1 with frame title text-001.
    parameter: fname type rlgrap-filename  default 'c:\supplies.xls'.
    parameters: p_begcol type i default '1' no-display,
                p_begrow type i default '2' no-display,
                p_endcol type i default '200' no-display,
                p_endrow type i default '2500' no-display.
    *perform f_get_data.
    selection-screen end of block b1.
    *DECLARATION OF EXCELAL TABLE
    at selection-screen on value-request for fname.
    perform f_get_file using fname.
    start-of-selection.
    perform f_xls_itab using fname
                       changing it_excel.
    perform f_move_data.
    perform f_get_data.
    perform f_call_bapi.
    *&      Form  F_GET_FILE
          text
         -->P_FNAME  text
         <--P_SY_SUBRC  text
    form f_get_file  using    p_fname like fname.
    call function 'KD_GET_FILENAME_ON_F4'
    exporting
       program_name        = syst-repid
       dynpro_number       = syst-dynnr
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      changing
        file_name           = p_fname
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    if sy-subrc <>  0.
    message e006(zhnc).
    endif.
    endform.                    " F_GET_FILE
    *&      Form  F_XLS_ITAB
          text
         -->P_FNAME  text
         <--P_IT_EXCEL  text
    form f_xls_itab  using    p_fname
                     changing p_it_excel.
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      = 'c:\supplies.xls'
        i_begin_col                   = p_begcol
        i_begin_row                   = p_begrow
        i_end_col                     = p_endcol
        i_end_row                     = p_endrow
      tables
        intern                        = it_excel
    exceptions
       inconsistent_parameters       = 1
       upload_ole                    = 2
       others                        = 3.
    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.                    " F_XLS_ITAB
    *&      Form  F_MOVE_DATA
          text
    -->  p1        text
    <--  p2        text
    form f_move_data .
    data : lv_index type i.
    field-symbols <fs>.
    *--- Sorting the internal table
    sort it_excel by row col.
    clear it_excel.
    loop at it_excel.
    move it_excel-col to lv_index.
    *--- Assigning the each record to an internal table row
    assign component lv_index of structure wa_data to <fs>.
    *--- Asigning the field value to a field symbol
    move it_excel-value to <fs>.
    at end of row.
    append wa_data to it_data.
    clear wa_data.
    endat.
    endloop.
    endform.                    " F_MOVE_DATA
    form f_get_data .
    loop at it_data into wa_data.
    move-corresponding wa_data to ihead_data.
    Header
        ihead_data-material       = wa_data-matnr.
        ihead_data-ind_sector     = wa_data-mbrsh.
        ihead_data-matl_type      = wa_data-mtart.
        ihead_data-basic_view     = 'X'.
        ihead_data-purchase_view  = 'X'.
        ihead_data-mrp_view       = 'X'.
        ihead_data-storage_view   = 'X'.
        ihead_data-quality_view   = 'X'.
        ihead_data-account_view   = 'X'.
        move-corresponding wa_data to iclient_data.
    Material Description
        refresh it_makt.
        it_makt-langu              = 'EN'.
        it_makt-matl_desc          =  wa_data-maktx.
        append it_makt.
    Purchase Order Description
    clear:iltxt,iltxt[].
    concatenate wa_data-text1 wa_data-text2 wa_data-text3 wa_data-text4
    wa_data-text5 wa_data-text6 into potext
    separated by space.
    iltxt-applobject = 'MATERIAL'.
    iltxt-text_name  =  wa_data-matnr.
    iltxt-text_id    = 'BEST'.
    iltxt-langu      = sy-langu.
    iltxt-langu_iso  = 'EN'.
    iltxt-format_col = space.
    iltxt-text_line  = potext.
    append iltxt.
    Client Data - Basic
        iclient_data-matl_group     = wa_data-matkl.
        iclient_data-old_mat_no     = wa_data-bismt.
        iclient_data-base_uom       = wa_data-meins.
        iclient_data-document       = wa_data-dzeinr.
        iclient_data-unit_of_wt     = wa_data-gewei.
        iclient_data-division       = wa_data-spart.
        iclient_data-qm_procmnt     = wa_data-qmpur.
        iclient_data-pur_valkey     = wa_data-ekwsl.
        iclient_datax-matl_group    = 'X'.
        iclient_datax-old_mat_no    = 'X'.
        iclient_datax-base_uom      = 'X'.
        iclient_datax-po_unit       = 'X'.
        iclient_datax-document      = 'X'.
        iclient_datax-unit_of_wt    = 'X'.
        iclient_datax-division      = 'X'.
        iclient_datax-var_ord_un    = 'X'.
        iclient_data-pur_valkey    = 'X'.
    move-corresponding wa_data to iplant_data.
    Plant - Purchasing
        iplant_data-plant          = wa_data-werks.
        iplant_data-pur_group      = wa_data-ekgrp.
        iplant_data-gr_pr_time     = wa_data-webaz.
        iplant_datax-plant         = wa_data-werks.
        iplant_data-pur_group      = 'X'.
        iplant_datax-gr_pr_time     = 'X'.
    *MRP1 View
        iplant_data-mrp_type       = wa_data-dismm.
        iplant_data-reorder_pt     = wa_data-minbe.
        iplant_data-mrp_ctrler     = wa_data-dispo.
        iplant_data-lotsizekey     = wa_data-disls.
        iplant_data-max_stock      = wa_data-mabst .
        iplant_datax-mrp_type       = 'X'.
        iplant_datax-reorder_pt     = 'X'.
        iplant_datax-mrp_ctrler     = 'X'.
        iplant_datax-lotsizekey     = 'X'.
        iplant_datax-max_stock      = 'X'.
    *MRP2 View
        iplant_data-plnd_delry     = wa_data-plifz.
        iplant_data-sm_key         = wa_data-fhori.
        iplant_data-ctrl_key       = wa_data-qsspur.
        iplant_data-availcheck     = wa_data-mtvfp.
        iplant_datax-plnd_delry     = 'X'.
        iplant_datax-sm_key         = 'X'.
        iplant_data-ctrl_key        = 'X'.
        iplant_datax-availcheck     = 'X'.
    *MRP3 View
       iplant_data-safety_stk     = wa_data-eisbe.
       iplant_data-qm_authgrp     = wa_data-qmatauth.
       iplant_datax-safety_stk     = 'X'.
       iplant_data-qm_authgrp      = 'X'.
    move-corresponding wa_data to istoragelocationdata.
    Storage View
        istoragelocationdata-plant        = wa_data-werks.
        istoragelocationdata-stge_loc     = wa_data-lgort_d.
        istoragelocationdata-stge_bin     = wa_data-lgpbe.
        istoragelocationdatax-plant        = wa_data-werks.
        istoragelocationdatax-stge_loc     = wa_data-lgort_d.
        istoragelocationdatax-stge_bin     = 'X'.
    Accounting
        iaccounting_data-val_area   = wa_data-werks.
        iaccounting_data-price_ctrl = wa_data-vprsv.
        iaccounting_data-moving_pr  = wa_data-verpr_bapi.
        iaccounting_data-price_unit = wa_data-peinh.
        iaccounting_data-val_class  = wa_data-bklas.
        iaccounting_data-val_cat    = wa_data-bwtty_d.
        iaccounting_datax-val_area   = wa_data-werks.
        iaccounting_datax-price_ctrl = 'X'.
        iaccounting_datax-moving_pr  = 'X'.
        iaccounting_datax-price_unit = 'X'.
        iaccounting_datax-val_class  = 'X'.
        iaccounting_datax-val_cat    = 'X'.
    clear it_ret.
    refresh it_ret.
    perform f_call_bapi.
    read table it_ret with key type = 'S'.
    if sy-subrc eq 0.
    perform f_bapi_commit.
    write:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',
    wa_data-matnr.
    else.
    *message e000(zhnc) with 'ERROR IN CREATING THE MATERIAL'.
    *WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.
    *PERFORM F_DOWNLOAD.
    endif.
    *ENDIF.
    endloop.
    endform.                    " F_GET_DATA
    *&      Form  F_CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    form f_call_bapi .
    call function 'BAPI_MATERIAL_SAVEDATA'
       exporting
         headdata                   = ihead_data
         clientdata                 = iclient_data
         clientdatax                = iclient_datax
         plantdata                  = iplant_data
         plantdatax                 = iplant_datax
       FORECASTPARAMETERS         =
       FORECASTPARAMETERSX        =
       PLANNINGDATA               =
       PLANNINGDATAX              =
        storagelocationdata        = istoragelocationdata
        storagelocationdatax       = istoragelocationdatax
         valuationdata              = iaccounting_data
         valuationdatax             = iaccounting_datax
       WAREHOUSENUMBERDATA        =
       WAREHOUSENUMBERDATAX       =
       SALESDATA                  =
       SALESDATAX                 =
       STORAGETYPEDATA             = istoragelocationdata
       STORAGETYPEDATAX            = istoragelocationdatax
       FLAG_ONLINE                = ' '
       FLAG_CAD_CALL              = ' '
       NO_DEQUEUE                 = ' '
       NO_ROLLBACK_WORK           = ' '
      importing
        return                     = it_ret
      tables
        materialdescription        = it_makt
       UNITSOFMEASURE             = it_uom
       UNITSOFMEASUREX            = it_uomx
      INTERNATIONALARTNOS        =
         materiallongtext          = iltxt
       TAXCLASSIFICATIONS        =
        returnmessages             = returnm.
       PRTDATA                   =
       PRTDATAX                  =
       EXTENSIONIN               =
       EXTENSIONINX              =
    append it_ret.
    write: it_ret-message .
    endform.                    " F_CALL_BAPI
    *&      Form  F_BAPI_COMMIT
          text
    -->  p1        text
    <--  p2        text
    form f_bapi_commit .
    call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT         =
    IMPORTING
      RETURN        =
    endform.                    " F_BAPI_COMMIT
    Plz suggest some solution.
    Best Regards,
    Ravi

    Hi,
    Insert Material number in the MAKT(Material Description table).
    Also, check if the material number is missing somewhere else...
    Regards,
    Kunjal

  • "Cannot interpret data in file" error while using GUI_UPLOAD for .xls file

    Hi,
         I have made a program using FM GUI_UPLOAD to upload an .xls file to an internal table. But upon executing ,it gives error "Cannot Interpret data in file". I have seen in other posts people talking about GUI_UPLOAD FM to upload data from excel directly into internal table. Kindly help.
    Here is my code. I had tried using different combination for HAS_FIELD_SEPARATOR but still its not working.
    In my emp1.xls file , the data in each column is present in the same order as in the internal table. Although the first column in my internal table is NUMC. I dont know if that is causing the problem.
    REPORT  ZUPLOAD_1.
    data: itab TYPE TABLE OF zempl_master WITH HEADER LINE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'C:\empl1.xls'
        FILETYPE                      = 'ASC'
        HAS_FIELD_SEPARATOR           = 'X'
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   CHECK_BOM                     = ' '
    *   VIRUS_SCAN_PROFILE            =
    *   NO_AUTH_CHECK                 = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      TABLES
        DATA_TAB                      = itab.
    * EXCEPTIONS
    *   FILE_OPEN_ERROR               = 1
    *   FILE_READ_ERROR               = 2
    *   NO_BATCH                      = 3
    *   GUI_REFUSE_FILETRANSFER       = 4
    *   INVALID_TYPE                  = 5
    *   NO_AUTHORITY                  = 6
    *   UNKNOWN_ERROR                 = 7
    *   BAD_DATA_FORMAT               = 8
    *   HEADER_NOT_ALLOWED            = 9
    *   SEPARATOR_NOT_ALLOWED         = 10
    *   HEADER_TOO_LONG               = 11
    *   UNKNOWN_DP_ERROR              = 12
    *   ACCESS_DENIED                 = 13
    *   DP_OUT_OF_MEMORY              = 14
    *   DISK_FULL                     = 15
    *   DP_TIMEOUT                    = 16
    *   OTHERS                        = 17
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP at itab.
      write:/ itab-emp_no,itab-name.
    endloop.

    hi amber22 you need to use the below fm to upload an xls file
    FORM EXCEL_UPLOAD .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = FILENAM
          I_BEGIN_COL = 1
          I_BEGIN_ROW = 1
          I_END_COL   = 6
          I_END_ROW   = 100
        TABLES
          INTERN      = xl_itab.
    * EXCEPTIONS
    * INCONSISTENT_PARAMETERS = 1
    * UPLOAD_OLE = 2
    * OTHERS = 3 .
      IF SY-SUBRC = 0.
    MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " EXCEL_UPLOAD

  • Call transaction error handling

    how to maintain the log i.e sucess/failures like below.
    Line No.     Success/ Failure  Document No     Error Details
    1     S     Doc 740000001     
    2     S     Doc 740000002     
    3     F          Co- code does not exist
    4     F          GL Account does not exist
    I'm getting only one last document no: but i need all the documents to be displayed i.e either success/failures.
    below is my code.
    TYPES: BEGIN OF ty_filedata,
           bukrs TYPE bukrs,           "Company code
           blart TYPE blart,           "Document type
           bldat TYPE char10,          "Document Date
           budat TYPE char10,          "Posting date
           xblnr TYPE xblnr,           "Reference
           bktxt TYPE bktxt,           "Document Header text
           waers TYPE waers,           "Currency
           newbs TYPE bschl,           "Posting Key for the next line item
           wrbtr TYPE char10,          "Amount
           zuonr LIKE bsik-zuonr,      "Assignment
           sgtxt TYPE sgtxt,           "Text
           newko TYPE hkont,           "Account for the next line item
           END OF ty_filedata.
    TYPES: BEGIN OF ty_detail_log,
             item_no TYPE i,        " Item line no.
             status(1) TYPE c,      " Status - success/failure
             doc_no TYPE bkpf-belnr," Document No.
             message TYPE string,   " Message
           END OF ty_detail_log.
    *&             DATA declaration of internal tables
         Internal Table declaration for excel data
    DATA:  it_itab TYPE STANDARD TABLE OF alsmex_tabline INITIAL SIZE 0,
        Internal Table declaration for upload data
          it_upload TYPE STANDARD TABLE OF ty_filedata INITIAL SIZE 0,
        Internal Table Declaration for BDCDATA
          it_bdcdata  TYPE STANDARD TABLE OF bdcdata,
        Internal Table Declaration for BDCMSGCOLL
          it_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll,
        Internal Table Declaration for FILENMAE
          lf_fname TYPE rlgrap-filename.
         t_err_log  TYPE STANDARD TABLE OF ty_err
                           INITIAL SIZE 0,  " table for validation error log
         t_DETAIL_LOG TYPE STANDARD TABLE OF TY_DETAIL_LOG.
         C_MSGNO TYPE BDC_MNR VALUE '312',
    *&             DATA declaration of work area
        Work Area declaration for Excel Data
    DATA: w_itab TYPE alsmex_tabline,
        Work Area declaration for upload data
          w_upload TYPE ty_filedata,
        Work Area declaration for upload data
          w_upload_n TYPE ty_filedata,
        Work Area declaration for upload data
          w_bdcdata TYPE bdcdata,
        Work Area declaration for upload data
          w_bdcmsgcoll TYPE bdcmsgcoll,
          w_detail_log TYPE ty_detail_log.
    *&                     SELECTION-SCREEN
    SELECTION-SCREEN: BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
    PARAMETERS:p_file TYPE rlgrap-filename.          " MODIF ID G1.
    SELECTION-SCREEN:  END OF BLOCK bk1.
    *&                             AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          dynpro_number = syst-dynnr
        CHANGING
          file_name     = p_file
        EXCEPTIONS
          mask_too_long = 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.
    *&                     START-OF-SELECTION
    START-OF-SELECTION.
      DATA:  lw_itab TYPE alsmex_tabline.
      lf_fname = p_file.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = lf_fname
          i_begin_col             = '1'
          i_begin_row             = '6'
          i_end_col               = '12'
          i_end_row               = '999'
        TABLES
          intern                  = it_itab[]
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    *MESSAGE S205(ZF_COMMON_MSGS_FIN1) DISPLAY LIKE C_E.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ELSE.
      IF it_itab IS NOT INITIAL.
        SORT it_itab BY row col.
    DELETE it_itab WHERE row LT 6.
        LOOP AT it_itab INTO lw_itab.
          w_itab = lw_itab.
          AT NEW row.
            CLEAR: w_upload.
          ENDAT.
          CASE w_itab-col.
            WHEN '0001'.
              w_upload-bukrs = w_itab-value.
            WHEN '0002'.
              w_upload-blart = w_itab-value.
            WHEN '0003'.
              w_upload-bldat = w_itab-value.
            WHEN '0004'.
              w_upload-budat = w_itab-value.
            WHEN '0005'.
              w_upload-xblnr = w_itab-value.
            WHEN '0006'.
              w_upload-bktxt = w_itab-value.
            WHEN '0007'.
              w_upload-waers = w_itab-value.
            WHEN '0008'.
              w_upload-newbs = w_itab-value.
            WHEN '0009'.
              w_upload-wrbtr = w_itab-value.
            WHEN '0010'..
              w_upload-zuonr = w_itab-value.
            WHEN '0011'.
              w_upload-sgtxt = w_itab-value.
            WHEN '0012'.
              w_upload-newko = w_itab-value.
          ENDCASE.
          AT END OF row.
            APPEND w_upload TO it_upload.
            CLEAR: w_upload.
          ENDAT.
        ENDLOOP.
    *endif.
      ENDIF.
      DATA: lw_upload TYPE ty_filedata,
            lv_lines TYPE sy-tabix,
            lv_index TYPE sy-tabix.
      DESCRIBE TABLE it_upload LINES lv_lines.
      LOOP AT it_upload INTO lw_upload.
        lv_index = sy-tabix.
        w_upload = lw_upload.
        IF NOT w_upload-bukrs IS INITIAL.
          IF lv_index GT 1.
           CALL TRANSACTION 'FB01' USING it_bdcdata
                   MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsgcoll.
           PERFORM fr_format_message_text.
            REFRESH: it_bdcdata.
          ENDIF.
          PERFORM bdc_dynpro      USING 'SAPMF05A' '0100'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'BKPF-XBLNR'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '/00'.
          PERFORM bdc_field       USING 'BKPF-BLDAT'
                                        w_upload-bldat.
          PERFORM bdc_field       USING 'BKPF-BLART'
                                        w_upload-blart.
          PERFORM bdc_field       USING 'BKPF-BUKRS'
                                        w_upload-bukrs.
          PERFORM bdc_field       USING 'BKPF-BUDAT'
                                        w_upload-budat.
          PERFORM bdc_field       USING 'BKPF-WAERS'
                                        w_upload-waers.
          PERFORM bdc_field       USING 'BKPF-XBLNR'
                                        w_upload-xblnr.
    *perform bdc_field       using 'FS006-DOCID'
          PERFORM bdc_field       USING 'RF05A-NEWBS'
                                        w_upload-newbs.
          PERFORM bdc_field       USING 'RF05A-NEWKO'
                                        w_upload-newko.
        ENDIF.
        IF lv_index NE lv_lines.
          lv_index = lv_index + 1.
          READ TABLE it_upload INTO w_upload_n INDEX lv_index.
          PERFORM bdc_dynpro      USING 'SAPMF05A' '0300'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'BSEG-WRBTR'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '/00'.
          PERFORM bdc_field       USING 'BSEG-WRBTR'
                                        w_upload-wrbtr.
          PERFORM bdc_field       USING 'RF05A-NEWBS'
                                  w_upload_n-newbs.
          PERFORM bdc_field       USING 'RF05A-NEWKO'
                                  w_upload_n-newko.
        ELSE.
          PERFORM bdc_dynpro      USING 'SAPMF05A' '0300'.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        'BSEG-WRBTR'.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=BU'.
          PERFORM bdc_field       USING 'BSEG-WRBTR'
                                       w_upload-wrbtr.
        ENDIF.
        PERFORM bdc_dynpro      USING 'SAPLKACB' '0002'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'COBL-ANLN1'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=ENTE'.
      ENDLOOP.
      CALL TRANSACTION 'FB01' USING it_bdcdata
              MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsgcoll.
      PERFORM fr_format_message_text .
      REFRESH: it_bdcdata.
    *&      Form  BDC_DYNPRO
    FORM bdc_dynpro USING program  dynpro.
      CLEAR w_bdcdata.
      w_bdcdata-program  = program.
      w_bdcdata-dynpro   = dynpro.
      w_bdcdata-dynbegin = 'X'.
      APPEND w_bdcdata TO it_bdcdata.
    ENDFORM.                    "BDC_DYNPRO
           Insert field                                                  *
    FORM bdc_field USING fnam fval.
      IF fval <> space.
        CLEAR w_bdcdata.
        w_bdcdata-fnam = fnam.
        w_bdcdata-fval = fval.
        APPEND w_bdcdata TO it_bdcdata.
      ENDIF.
    ENDFORM.                    "BDC_FIELD
    *&      Form  fr_format_message_text
    FORM fr_format_message_text.
      DATA: lf_msg   TYPE string.
      WRITE:/ sy-uline(125).
      FORMAT COLOR 1 INTENSIFIED ON.
      WRITE : /1 sy-vline,
               2  text-041 ,  "'record Number',
               16 sy-vline,
               17 text-042 ,  " 'success/failure',
               35  sy-vline,
               36 text-043,   " 'document no',
               55 sy-vline,
               56 text-044,   "'Error details',
               125 sy-vline.
      WRITE:/ sy-uline(125).
      LOOP AT it_bdcmsgcoll INTO w_bdcmsgcoll.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = w_bdcmsgcoll-msgid
            lang      = sy-langu
            no        = w_bdcmsgcoll-msgnr
            v1        = w_bdcmsgcoll-msgv1
            v2        = w_bdcmsgcoll-msgv2
            v3        = w_bdcmsgcoll-msgv3
            v4        = w_bdcmsgcoll-msgv4
          IMPORTING
            msg       = lf_msg
          EXCEPTIONS
            not_found = 1
            OTHERS    = 2.
        IF sy-subrc EQ 0.
          WRITE:/01 sy-vline,
                  02 sy-tabix,
                  16 sy-vline,
                  17 w_bdcmsgcoll-msgtyp,
                  35 sy-vline,
                  36 w_bdcmsgcoll-msgv1,
                  55 sy-vline,
                  56 lf_msg,
                  125 sy-vline.
          WRITE:/ sy-uline(125).
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "fr_format_message_text
    Thanks in advance.

    Hi Neelima,
    Just put the following code within that LOOP...ENDLOOP statement.
    LOOP AT it_upload INTO lw_upload.
      CALL TRANSACTION 'FB01' USING it_bdcdata
      MODE 'N' UPDATE 'S' MESSAGES INTO it_bdcmsgcoll.
      PERFORM fr_format_message_text .
      REFRESH: it_bdcdata.
    ENDLOOP.
    Regards,
    R.Nagarajan.
    We can -

  • It has an error when run a program in background job

    Dear Expert,
    we have a program
    when run it in background,it has a error "Error during import of clipboard contents" but when run it normally(run in front workbench se38 or run the t-code),everything is ok.i've used typingJDBG in the command box to debuge the background job,there has no error.
    whould you like to tell me what had happen? thanks a lot!
    addition: the program used a function ALSM_EXCEL_TO_INTERNAL_TABLE
    Thanks & Regards,
    Kerry
    Edited by: Kerry Wang on Aug 24, 2009 2:12 PM
    Edited by: Kerry Wang on Aug 24, 2009 2:14 PM
    Edited by: Kerry Wang on Aug 24, 2009 2:14 PM

    Hi,
      You cannot use FMs to get data directly from the presentation server when program is executed in the backgroud.
    Check the thread : GUI_DOWNLOAD
    Regards,
    Himanshu

  • Error while using the function module GUI_UPLOAD

    Hi,
    My requirement is to upload the data from .txt file into internal table.
    I have given my code like this
    PARAMETERS: p_fname LIKE rlgrap-filename.
    data: begin of gt_string occurs 0,
           record type char255,
          end of gt_string.
    AT SELECTION-SCREEN ON VALUE-REQUEST for p_fname.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
       EXPORTING
        PROGRAM_NAME        = SYST-REPID
        DYNPRO_NUMBER       = SYST-DYNNR
        FIELD_NAME          = ' '
         STATIC              = 'X'
        MASK                = ' '
        CHANGING
          file_name           = p_fname
       EXCEPTIONS
         MASK_TOO_LONG       = 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_UPLOAD'
        EXPORTING
          filename                      = p_fname
         FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
         HEADER_LENGTH                 = 0
        READ_BY_LINE                  = 'X'
        DAT_MODE                      = ' '
        CODEPAGE                      = ' '
        IGNORE_CERR                   = ABAP_TRUE
        REPLACEMENT                   = '#'
        CHECK_BOM                     = ' '
        NO_AUTH_CHECK                 = ' '
      IMPORTING
        FILELENGTH                    =
        HEADER                        =
        tables
          data_tab                      = gt_string
       EXCEPTIONS
         FILE_OPEN_ERROR               = 1
         FILE_READ_ERROR               = 2
         NO_BATCH                      = 3
         GUI_REFUSE_FILETRANSFER       = 4
         INVALID_TYPE                  = 5
         NO_AUTHORITY                  = 6
         UNKNOWN_ERROR                 = 7
         BAD_DATA_FORMAT               = 8
         HEADER_NOT_ALLOWED            = 9
         SEPARATOR_NOT_ALLOWED         = 10
         HEADER_TOO_LONG               = 11
         UNKNOWN_DP_ERROR              = 12
         ACCESS_DENIED                 = 13
         DP_OUT_OF_MEMORY              = 14
         DISK_FULL                     = 15
         DP_TIMEOUT                    = 16
         OTHERS                        = 17
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Here I am getting dump error as 'Type conflict when calling a function module.
    The function module interface allows you to specify only fields
    of a particular type under "FILENAME". The field "P_FNAME" specified here has a different field type'.
    What would be the reason for this error?
    Can anyone help me?
    Regards,
    Hema

    see this sample program for F4 help
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 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.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • ERROR while uploading data from EXCEl to sap using ALSM_EXCEL FUNCION MODULE

    Hi Experts,
    I am uploading excel data into sap suing function module ALSM_EXCEl_TO_INTERNAL_TABLE , used this funcion module in the program while running the program one blank excel sheet is opening and data is not uploading into internal table . even same blank sheet is opeining if we user
    CONVERT_EXCEL_TO_INTERNAL function module also.
    can you please tell me why this error is coming how to over come this error.
    My excel sheet data records are less then 10000.
    Thanks & regards
    kiran

    Hi Taranam,
    Use FM ALSM_EXCEL_TO_INTERNAL_TABLE.
    Regards,
    Atish

  • Error while execution in background

    Hi all
    when iam using file download function , it is working fine in foreground but giving
    error dump while executing in background
    plz reply , its urgent

    Hi Check this link it will solves ur problem...
    http://www.sap-img.com/ab004.htm
    <b>i am pasting the same information below......</b>
    GUI_* WS_* Function In Background, CSV Upload
    GUI_* and WS_* function modules do not work in background
    When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
    At anytime, a user can switch of the Personal Computers even though the job is still running in the background.  Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer  file.
    To choose the correct download method to used, you can check the value of SY-BATCH in your code,
    if it is 'X' use OPEN DATASET and if it is ' ' use WS_UPLOAD.
    *-- Open dataset for reading
    DATA:
      dsn(20) VALUE '/usr/test.dat',
      rec(80).
    OPEN DATASET dsn FOR INPUT IN TEXT MODE.
    IF sy-subrc = 0.
      DO.
        READ DATASET dsn INTO rec.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
          WRITE / rec.
        ENDIF.
      ENDDO.
    ENDIF.
    CLOSE DATASET dsn.
    *-- Open dataset for writing
    DATA rec(80).
    OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.
      TRANSFER rec TO '/usr/test.dat'.
    CLOSE DATASET dsn.
    What is the difference when we use upload, ws_upload, gui_upload function modules?
    UPLOAD, WS_UPLOAD, GUI_UPLOAD, are used in BDC concepts.  ie., Batch Data Communication.
    Batch Data Conversion is a concept where user can transfer the Data from non SAP to SAP R/3.  So , in these various Function Modules are used.
    UPLOAD---  upload a file to the presentation server (PC)
    WS_UPLOAD----    Load Files from the Presentation Server to Internal ABAP Tables.
    WS means Work Station.
    This is used upto SAP 4.6 version.
    GUI_UPLOAD-------    Replaces WS_UPLOAD. Upoad file from presentation server to the app server.  From 4.7 SAP version it is replaced.
    How to Upload csv file to SAP?
    Common File Download Upload Questions:
    How  you upload the data from text file to sap internal table?  From my knowledge its by upload or gui_upload. 
    How you download the data from sap internal table to text file?
    How  you upload the data from xls (excel) file to sap internal table how you download the data from sap internal table to xls(excel) file.
    You can upload data from presentation server to an internal table using gui_upload. Use gui_download to download from internal table to flat file.
    Use fm ALSM_EXCEL_TO_INTERNAL_TABLE to upload data frm excel.
    Use function module GUI_UPLOAD
    The FILETYPE refer to the type of file format you need: For e.g 'WK1' - Excel format , 'ASC' - Text Format etc.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'C:\test.csv'
       FILETYPE                      = 'ASC'
      TABLES
        DATA_TAB                      = itab
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17.
    Ramesh

  • Error while uploading data to ztable from excel file

    Hi,
    I have a requirement where i have to upload data from excel file to ztable.I have used the fm 'ALSM_EXCEL_TO_INTERNAL_TABLE' for reading the excel file.After reading the excel file i have used INSERT zrb_hdr from table t_zrb_hdr for updating the ztable with data .
    here it is giving error as the data base table zrb_hdr and the internal table t_zrb_hdr should be declared of same type .
    I got this error b'coz i have changed the date and time fields in t_zrb_hdr table to char type.so the structure of zrb_hdr and t_zrb_hdr are not same.If i don't change the date and time fields,in the o/p i am not getting proper date and time formats.
    now how can i upload data into ztable?

    Hi,
    Try this.
    Data: itab type standard table of ztable,
             wa_itab type ztable.
    loop at t_zrb_hdr into wa_t_zrb_hdr.
       wa_itab-date = wa_t_zrb_hdr-date.
       wa_itab-time = wa_t_zrb_hdr-time.
       like  move all the fiedl to wa_itab...........
       append itab with wa_itab.
    Endloop.
    now insert the records from itab to the database table ztable.
    Thanks,
    Muthu.

  • Error in PO using  BAPI_PO_CREATE1

    Hi ,
    I got a error in the po  that in my template the netpr is 8.00 but in the output always displaying the amount 1.00 only in POITEM-NET_PRICE.even i change in the template different values but no change in the output.why like this and how to solve this.
    Thanks,
    Regards,
    Rajendra.

    Hi Eswar,
           Below is the code,
    tables: T100.
    DATA : POHEADER         LIKE BAPIMEPOHEADER ,    
           POHEADERX        LIKE BAPIMEPOHEADERX,   
           POITEM           LIKE BAPIMEPOITEM     OCCURS 0 WITH HEADER LINE,
           POITEMX          LIKE BAPIMEPOITEMX    OCCURS 0 WITH HEADER LINE,
           POSCHEDULE       LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE,
           POSCHEDULEX      LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE,
           POACCOUNT        LIKE BAPIMEPOACCOUNT  OCCURS 0 WITH HEADER LINE,
           POACCOUNTX       LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE,
           POCOND           LIKE BAPIMEPOCOND     OCCURS 0 WITH HEADER LINE,
           POCONDX          LIKE BAPIMEPOCONDX    OCCURS 0 WITH HEADER LINE,
           RETURN           LIKE BAPIRET2         OCCURS 0 WITH HEADER LINE,
           EXPPURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.
           POHEADER-COMP_CODE = '2006'.
    DATA : BEGIN OF DATA_TAB OCCURS 0,
               BSART(4)  TYPE C,
               LIFNR(10) TYPE C,
               EKORG(4)  TYPE C,
               EKGRP(3)  TYPE C,
               EBELP(5)  TYPE C,
               MATNR(18) TYPE C,
               MAKTX(40) TYPE C,
               WERKS(4)  TYPE C,
               CHARG(10) TYPE C,
               BEDNR(10) TYPE C,
               PSTYP(1)  TYPE C,
               KNTTP(1)  TYPE C,
               ANLN1(12) TYPE C,
               ANLN2(4)  TYPE C,
               AUFNR(12) TYPE C,
               PS_PSP_PNR(8) TYPE C,
               EINDT(8)  TYPE C,
               WAERS(5)  TYPE C,
               NETPR(11) TYPE C,
               WKURS(9)  TYPE C,
               BEDAT(8)  TYPE C,
               SAKTO(10) TYPE C,
               KOSTL(10) TYPE C,
               MENGE(13) TYPE C,
               MEINS(3)  TYPE C,
               KWERT(13) TYPE C,
               KSCHL(4)  TYPE C,
            END OF DATA_TAB.
    Data
    DATA : wc_file    type string,
           wc_tabix   like sy-tabix,
           wc_fl(40)  type c,
           wc_tot(19) type n.
    data: i_tab1        like alsmex_tabline occurs 0 with header line,
         w_Data_tab    like Data_tab occurs 0 with header line,
          w_Data_tab    like Data_tab,
          w_totlines    type i,
          w_end_col     type i.
    DATA : C_X(1) TYPE c VALUE 'X'.
    DATA : W_ERRSTAT(18)   TYPE C.
    DATA : W_ERRMSG(18)    TYPE C.
    DATA : I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF I_RETURN OCCURS 0.
    DATA : EBELN   LIKE EKKO-EBELN.
            INCLUDE STRUCTURE DATA_TAB.
    DATA : MESSAGE LIKE RETURN-MESSAGE.
    DATA : END OF I_RETURN.
    ALV
    type-pools: slis.
    data: txt_report          like dokhl-object. "Reportname für Erläuterungsaufruf
    data: gt_fieldcat         type slis_t_fieldcat_alv,
          gt_events           type slis_t_event,
          gt_sort             type slis_t_sortinfo_alv,
          gt_list_top_of_page type slis_t_listheader,
          gs_layout           type slis_layout_alv.
    *Parameters
    selection-screen begin of block mysel1 with frame.
    parameters: pc_file like rlgrap-filename.  " obligatory default 'C:'." default 'C:mat.xls'.
    selection-screen end of block mysel1.
    *AT SELECTION-SCREEN
    at selection-screen on pc_file.
    call function 'WS_QUERY'
           exporting
                query    = 'FL'
                filename = pc_file
           importing
                return   = wc_fl.
           condense wc_fl no-gaps.
        if wc_fl eq space.
          message e009 raising pc_file.
           exit.
        endif.
    at selection-screen on value-request for pc_file.
                   wc_file = pc_file.
    call function 'WS_FILENAME_GET'
         exporting
               mask        = ' '
               title       = text-001
        importing
               filename    = pc_file
        exceptions
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          others           = 5.
    SELECTION-SCREEN
    start-of-selection.
              perform 1000_getfile.
              perform 2000_process_bapi.
              perform fieldcat_init  using gt_fieldcat[].
              perform layout_init    using gs_layout.
              perform comment_build  using gt_list_top_of_page[].
              perform eventtab_build using gt_events[].
              PERFORM sort_build     USING gt_sort[].
              perform 3000_updation_log.
       end-of-selection.
    *&      Form  1000_getfile
          text
    -->  p1        text
    <--  p2        text
    FORM 1000_getfile .
    *w_data_tab = data_tab.
    Get the No of Rows in the file
                      CALL FUNCTION 'AA_FILE_UPLOAD_EXCEL'
                        EXPORTING
                          I_FILENAME                 = pc_file
                        I_TEST                     =
                        I_UCOMM                    =
                        I_MAXCOLS                  =
                         I_DELIMITER                = ','
                        TABLES
                          ET_FILECONTENT             = DATA_TAB
                       EXCEPTIONS
                         ERROR_ACCESSING_FILE       = 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.
         describe table Data_tab lines w_totlines.
         w_end_col = 27.
        w_totlines = 1.
    Upload the data from file to Internal Table
         refresh Data_tab.
       call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
             exporting
                  filename    = pc_file
                  i_begin_col = 1 " Starting col on each row from the upload excel file
                  i_begin_row = 4 " Starting row from the upload excel file
                  i_end_col   = w_end_col " No. of columns in the upload excel file
                  i_end_row   = w_totlines " Possible no. of rows in the upload excel file
             tables
                   intern     = i_tab1
             exceptions
                   inconsistent_parameters = 1
                   upload_ole              = 2
                   others                  = 3.
             endif.
        sort i_tab1 by row col.
        loop at i_tab1.
           case i_tab1-col.
          when 1.
             clear w_Data_tab.
              move i_tab1-value to w_Data_tab-bsart.
          when 2.
              move i_tab1-value to w_Data_tab-lifnr.
          when 3.
              move i_tab1-value to w_Data_tab-ekorg.
          when 4.
              move i_tab1-value to w_Data_tab-ekgrp.
          when 5.
              move i_tab1-value to w_Data_tab-ebelp.
          when 6.
              move i_tab1-value to w_Data_tab-matnr.
          when 7.
              move i_tab1-value to w_Data_tab-maktx.
          when 8.
              move i_tab1-value to w_Data_tab-werks.
          when 9.
              move i_tab1-value to w_Data_tab-charg.
          when 10.
              move i_tab1-value to w_Data_tab-bednr.
          when 11.
              move i_tab1-value to w_Data_tab-pstyp.
          when 12.
              move i_tab1-value to w_Data_tab-knttp.
          when 13.
              move i_tab1-value to w_Data_tab-anln1.
          when 14.
              move i_tab1-value to w_Data_tab-anln2.
          when 15.
              move i_tab1-value to w_Data_tab-aufnr.
          when 16.
              move i_tab1-value to w_Data_tab-ps_psp_pnr.
          when 17.
              move i_tab1-value to w_Data_tab-eindt.
          when 18.
              move i_tab1-value to w_Data_tab-waers.
          when 19.
              move i_tab1-value to w_Data_tab-netpr.
          when 20.
              move i_tab1-value to w_Data_tab-wkurs.
          when 21.
              move i_tab1-value to w_Data_tab-bedat.
          when 22.
              move i_tab1-value to w_Data_tab-sakto.
          when 23.
              move i_tab1-value to w_Data_tab-kostl.
          when 24.
              move i_tab1-value to w_Data_tab-menge.
          when 25.
              move i_tab1-value to w_Data_tab-meins.
          when 26.
              move i_tab1-value to w_Data_tab-kwert.
          when 27.
              move i_tab1-value to w_Data_tab-kschl.
         endcase.
            at end of row.
              append w_Data_tab to Data_tab.
              clear  w_Data_tab.
             endat.
        endloop.
              clear wc_tot.
              describe table Data_tab lines wc_tot.
    ENDFORM.                                      " 1000_getfile
    *&      Form  2000_process_bapi
          text
    -->  p1        text
    <--  p2        text
    FORM 2000_process_bapi .
    LOOP AT DATA_TAB.
      POHEADER-DOC_TYPE   = DATA_TAB-BSART.
      POHEADER-VENDOR     = DATA_TAB-LIFNR.
      POHEADER-PURCH_ORG  = DATA_TAB-EKORG.
      POHEADER-PUR_GROUP  = DATA_TAB-EKGRP.
      POHEADER-DOC_DATE   = DATA_TAB-BEDAT.
      POHEADER-EXCH_RATE  = DATA_TAB-WKURS.
      POHEADER-CURRENCY   = DATA_TAB-WAERS.
    APPEND POHEADER.
      POHEADERX-DOC_TYPE   = 'X'.
      POHEADERX-VENDOR     = 'X'.
      POHEADERX-PURCH_ORG  = 'X'.
      POHEADERX-PUR_GROUP  = 'X'.
      POHEADERX-DOC_DATE   = 'X'.
      POHEADERX-EXCH_RATE  = 'X'.
      POHEADERX-CURRENCY   = 'X'.
    APPEND POHEADERX.
      POITEM-PO_ITEM        = DATA_TAB-EBELP.
      POITEM-MATERIAL       = DATA_TAB-MATNR.
    POITEM-SHORT_TEXT     = DATA_TAB-MAKTX.
      POITEM-PLANT          = DATA_TAB-WERKS.
      POITEM-BATCH          = DATA_TAB-CHARG.
      POITEM-TRACKINGNO     = DATA_TAB-BEDNR.
      POITEM-ITEM_CAT       = DATA_TAB-PSTYP.
      POITEM-ACCTASSCAT     = DATA_TAB-KNTTP.
      POITEM-NET_PRICE      = DATA_TAB-NETPR.
      POITEM-QUANTITY       = DATA_TAB-MENGE.
      POITEM-PO_UNIT        = DATA_TAB-MEINS.
    APPEND POITEM.
      POITEMX-PO_ITEM             = DATA_TAB-EBELP.
    POITEMX-PO_ITEM        = 'X'.
      POITEMX-MATERIAL       = 'X'.
    POITEMX-SHORT_TEXT     = 'X'.
      POITEMX-PLANT          = 'X'.
      POITEMX-BATCH          = 'X'.
      POITEMX-TRACKINGNO     = 'X'.
      POITEMX-ITEM_CAT       = 'X'.
      POITEMX-ACCTASSCAT     = 'X'.
      POITEMX-NET_PRICE      = 'X'.
      POITEMX-QUANTITY       = 'X'.
      POITEMX-PO_UNIT        = 'X'.
    APPEND POITEMX.
      POACCOUNT-PO_ITEM           = DATA_TAB-EBELP.
      POACCOUNT-ASSET_NO     = DATA_TAB-ANLN1.
      POACCOUNT-SUB_NUMBER   = DATA_TAB-ANLN2.
      POACCOUNT-ORDERID      = DATA_TAB-AUFNR.
      POACCOUNT-WBS_ELEMENT  = DATA_TAB-PS_PSP_PNR.
      POACCOUNT-GL_ACCOUNT   = DATA_TAB-SAKTO.
      POACCOUNT-COSTCENTER   = DATA_TAB-KOSTL.
    POACCOUNT-QUANTITY           = DATA_TAB-MENGE.
    APPEND POACCOUNT.
      POACCOUNTX-PO_ITEM           = DATA_TAB-EBELP.
      POACCOUNTX-ASSET_NO    = 'X'.
      POACCOUNTX-SUB_NUMBER  = 'X'.
      POACCOUNTX-ORDERID     = 'X'.
      POACCOUNTX-WBS_ELEMENT = 'X'.
      POACCOUNTX-GL_ACCOUNT  = 'X'.
      POACCOUNTX-COSTCENTER  = 'X'.
    APPEND POACCOUNTX.
      POCOND-ITM_NUMBER              = DATA_TAB-EBELP.
      POCOND-COND_VALUE              = DATA_TAB-KWERT.
      POCOND-CURRENCY         = DATA_TAB-WAERS.
      POCOND-COND_TYPE        = DATA_TAB-KSCHL.
      POCOND-CHANGE_ID        = ' I '.
    APPEND POCOND.
      POCONDX-ITM_NUMBER             = DATA_TAB-EBELP.
      POCONDX-COND_VALUE             = 'X'.
      POCONDX-CURRENCY       = 'X'.
      POCONDx-COND_TYPE      = 'X'.
      POCONDx-CHANGE_ID       = ' I '.
    APPEND POCONDX.
      POSCHEDULE-PO_ITEM        = DATA_TAB-EBELP.
      POSCHEDULE-DELIVERY_DATE  = DATA_TAB-EINDT.
      POSCHEDULE-QUANTITY             = DATA_TAB-MENGE.
      APPEND POSCHEDULE.
      POSCHEDULEX-PO_ITEM        = DATA_TAB-EBELP.
      POSCHEDULEX-DELIVERY_DATE  = 'X'.
      POSCHEDULEx-QUANTITY             = 'X'.
    APPEND POSCHEDULEX.
    ENDLOOP.
    CALL FUNCTION 'BAPI_PO_CREATE1'
      EXPORTING
        POHEADER                     = POHEADER
        POHEADERX                    = POHEADERX
    IMPORTING
        EXPPURCHASEORDER             = EXPPURCHASEORDER
      EXPHEADER                    =
      EXPPOEXPIMPHEADER            =
    TABLES
        RETURN                       = RETURN
        POITEM                       = POITEM
        POITEMX                      = POITEMX
      POADDRDELIVERY               =
        POSCHEDULE                   = POSCHEDULE
        POSCHEDULEX                  = POSCHEDULEX
        POACCOUNT                    = POACCOUNT
      POACCOUNTPROFITSEGMENT       =
        POACCOUNTX                   = POACCOUNTX
      POCONDHEADER                 =
      POCONDHEADERX                =
        POCOND                       = POCOND
        POCONDX                      = POCONDX
      POPARTNER                    =
    IF SY-SUBRC = 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = C_X
    ENDIF.
    data : w_ekko like ekko-ebeln.
      LOOP AT DATA_TAB.
       READ TABLE RETURN index 1.
        MOVE-CORRESPONDING RETURN    TO I_RETURN.
        MOVE-CORRESPONDING DATA_TAB  TO I_RETURN.
      TO GET THE PO NUMBER     *************
       SELECT single EBELN  FROM EKKO INTO  w_EKKO
                          WHERE BSART EQ DATA_TAB-BSART
                            AND LIFNR EQ DATA_TAB-LIFNR
                            AND EKORG EQ DATA_TAB-EKORG
                            AND EKGRP EQ DATA_TAB-EKGRP.
               MOVE w_EKKO TO I_RETURN-EBELN.
        APPEND I_RETURN.
        CLEAR  I_RETURN.
      ENDLOOP.
      ENDFORM.                                     " 2000_process_bapi
    *&      Form  fieldcat_init
    FORM fieldcat_init  USING lt_fieldcat type slis_t_fieldcat_alv.
        data: ls_fieldcat type slis_fieldcat_alv.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'EBELN'.
    ls_fieldcat-datatype      = 'C'.
    ls_fieldcat-seltext_l     = text-001.
    ls_fieldcat-seltext_m     = text-001.
    ls_fieldcat-seltext_s     = text-001.
    ls_fieldcat-reptext_ddic  = text-001.
    ls_fieldcat-outputlen     = '10'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'WERKS'.
    ls_fieldcat-datatype      = 'C'.
    ls_fieldcat-seltext_l     = text-002.
    ls_fieldcat-seltext_m     = text-002.
    ls_fieldcat-seltext_s     = text-002.
    ls_fieldcat-reptext_ddic  = text-002.
    ls_fieldcat-outputlen     = '4'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'KNTTP'.
    ls_fieldcat-datatype      = 'C'.
    ls_fieldcat-seltext_l     = text-003.
    ls_fieldcat-seltext_m     = text-003.
    ls_fieldcat-seltext_s     = text-003.
    ls_fieldcat-reptext_ddic  = text-003.
    ls_fieldcat-outputlen     = '4'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'MATNR'.
    ls_fieldcat-datatype      = 'C'.
    ls_fieldcat-seltext_l     = text-004.
    ls_fieldcat-seltext_m     = text-004.
    ls_fieldcat-seltext_s     = text-004.
    ls_fieldcat-reptext_ddic  = text-004.
    ls_fieldcat-outputlen     = '18'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'MENGE'.
    ls_fieldcat-datatype      = 'C'.
    ls_fieldcat-seltext_l     = text-005.
    ls_fieldcat-seltext_m     = text-005.
    ls_fieldcat-seltext_s     = text-005.
    ls_fieldcat-reptext_ddic  = text-005.
    ls_fieldcat-outputlen     = '10'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'NETPR'.
    ls_fieldcat-datatype      = 'CURR'.
    ls_fieldcat-seltext_l     = text-006.
    ls_fieldcat-seltext_m     = text-006.
    ls_fieldcat-seltext_s     = text-006.
    ls_fieldcat-reptext_ddic  = text-006.
    ls_fieldcat-outputlen     = '11'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    ls_fieldcat-fieldname     = 'MESSAGE'.
    ls_fieldcat-datatype      = 'C'.
    ls_fieldcat-seltext_l     = text-007.
    ls_fieldcat-seltext_m     = text-007.
    ls_fieldcat-seltext_s     = text-007.
    ls_fieldcat-reptext_ddic  = text-007.
    ls_fieldcat-outputlen     = '50'.
    append ls_fieldcat to lt_fieldcat.
    clear ls_fieldcat.
    ENDFORM.                                       " fieldcat_init
    *&      Form  layout_init
          text
         -->P_GS_LAYOUT  text
    FORM layout_init  USING  ls_layout type slis_layout_alv.
          ls_layout-zebra = 'X'.
    ENDFORM.                                          " layout_init
    *&      Form  comment_build
          text
         -->P_GT_LIST_TOP_OF_PAGE[]  text
    FORM comment_build  USING Lt_top_of_page type slis_t_listheader.
      field-symbols: .
      data: ls_line type slis_listheader.
      data: i_sel   like textpool occurs 0 with header line.
            read  textpool sy-repid into i_sel language sy-langu.
            delete i_sel where id ne 'S'.
       LIST HEADING LINE: TYPE H
        clear ls_line.
          ls_line-typ    = 'H'.
          ls_line-info   = text-020.
        append ls_line to lt_top_of_page.
        clear ls_line.
          ls_line-typ    = 'S'.
          ls_line-key    = text-021.
        append ls_line to lt_top_of_page.
       Selection-screen
      loop at i_sel.
        assign (i_sel-key) to .
        append ls_line to lt_top_of_page.
    endloop.
    ENDFORM.                                          " comment_build
    *&      Form  eventtab_build
          text
         -->P_GT_EVENTS[]  text
    FORM eventtab_build  USING lt_events type slis_t_event.
    data: ls_event type slis_alv_event.
             move 'PF_STATUS_SET' to ls_event-name.
             move 'Z2006RMMPOUPLOAD' to ls_event-form.
          append ls_event to lt_events.
        clear ls_event.
    ENDFORM.                                          "eventtab_build
    FORM PF_STATUS_SET
    form Z2006RMMPOUPLOAD using extab type slis_t_extab. "#EC CALLED
             set pf-status 'Z2006RMMPOUPLOAD'. "EXCLUDING extab.
    endform.                                          "Z2006RMMPOUPLOAD
    FORM TOP_OF_PAGE *
    form top_of_page.
         call function 'REUSE_ALV_COMMENTARY_WRITE'
            exporting
                i_logo             = 'MECOMB'
                it_list_commentary = gt_list_top_of_page.
    endform.                                           "top_of_page
    *&      Form  3000_updation_log
    FORM 3000_updation_log .
                   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                    EXPORTING
                     I_INTERFACE_CHECK                 = ' '
                     I_BYPASSING_BUFFER                = ' '
                     I_BUFFER_ACTIVE                   = ' '
                       I_CALLBACK_PROGRAM                = 'Z2006RMMPOUPLOAD'
                     I_CALLBACK_PF_STATUS_SET          = ' '
                     I_CALLBACK_USER_COMMAND           = ' '
                       I_CALLBACK_TOP_OF_PAGE            = '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                         = gs_layout
                       IT_FIELDCAT                       = gt_fieldcat[]
                       IT_EVENTS                         = gt_events[]
                     TABLES
                       T_OUTTAB                          = I_RETURN
                     EXCEPTIONS
                       PROGRAM_ERROR                     = 1
                       OTHERS                            = 2
    ENDFORM.                                      " 3000_updation_log
    *&      Form  sort_build
    FORM sort_build  USING lt_sort type slis_t_sortinfo_alv.
    data: ls_sort type slis_sortinfo_alv.
    ls_sort-fieldname = 'EBELN'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    append ls_sort to lt_sort.
    clear ls_sort.
    ls_sort-fieldname = 'MATNR'.
    ls_sort-up = 'X'.
    append ls_sort to lt_sort.
    clear ls_sort.
    ENDFORM.                                          " sort_build
    Thanks,
    Rajendra.

Maybe you are looking for

  • Create an image from Component

    I have created an ImageLoader that stores images loaded from the filesystem. I do however need a default image that is not reliant on loading an image from the filesystem, in case any images on the filesystem are not found. I have tried to use Compon

  • Firefox Sync not working with weave server behind password protected proxy

    Since the sync is moved from firefox to Android, I'm completely unable to sync my bookmarks with my personal weave server. The server is internal, but accessible via a proxy with a username/password for all internal sites. Last working version was 10

  • Forcing the monitor to shut off -- fixed!

    Usually when I walk away from my computer, I shut the monitor off manually with the power button. However, the button is quite finicky, and I'd rather have an entry in my root window to shut off my monitor. So I figured out that the xset program can

  • Stacks not available in Collections?

    Is "Stacking" not available when working within a Collection? That is what it looks like to me for LR2. While in a Collection of pictures from a recent trip I selected 4 images. Stacking was grayed out (not available) in the Photo Menu. With those 4

  • EJB-Security client identification

    I want to be able to distinguish between different clients possibly running with the same client user IDs. The distinction has to be on the server side e.g. based on the client's IP address. Is it possible to get the client's IP address on the server