3 Replies Latest reply: Sep 7, 2007 3:40 PM by Srinivas Gummaluri RSS

F4_FILENAME

sachin sampras
Currently Being Moderated

HI

HOW CAN WE USE THIS FOR GETTING POSSIBLE ENTRIES IN AT SELECTION SCREEN AND FROM THAT WE HAVE TO UP LOAD A FLAT FILE USING GUI_UPLOAD

CAN ANY ONE TELL WITH EXAMPLE

  • Re: F4_FILENAME
    Rich Heilman
    Currently Being Moderated

    I would suggest to use this class method instead of that function module.

     

    
    
    report zrich_0001.
    
    data: ifiletable type filetable.
    data: xfiletable like line of ifiletable.
    data: rc type i.
    
    parameters: p_file1 type localfile default'C:test.txt'.
    
    at selection-screen on value-request for p_file1.
    
    call method cl_gui_frontend_services=>file_open_dialog
       EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
         INITIAL_DIRECTORY       = 'C:'
    *    MULTISELECTION          =
      changing
        file_table              = ifiletable
        rc                      = rc
    *    USER_ACTION             =
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        others                  = 4.
            .
     read table ifiletable into xfiletable index 1.
     if sy-subrc = 0.
      p_file1 = xfiletable-FILENAME.
     endif.
    
    

     

     

    Regards,

    Rich Heilman

  • Re: F4_FILENAME
    usa india
    Currently Being Moderated

    REPORT zmp_create_inv_data_from_file LINE-SIZE 0

                                         LINE-COUNT 65

                                         MESSAGE-ID zwm

                                         NO STANDARD PAGE HEADING.

     

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

    •             T A B L E S   A N D   S T R U C T U R E S                *

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

    TABLES: lagp,          "Storage bins

            marc,          "Plant Data for Material

            zwminvdat,     "WM Inventory Load Data

            zwminvdat_err. "WM Inventory Load Data - Errors

     

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

    •    S E L E C T  -  O P T I O N S   A N D   P A R A M E T E R S       *

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

    SELECTION-SCREEN SKIP 1.

     

    SELECTION-SCREEN BEGIN OF BLOCK file WITH FRAME.

    PARAMETERS: p_infile TYPE rlgrap-filename OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK file.

     

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

    •                  D A T A     D E F I N I T I O N                     *

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

     

    DATA: w_werks           LIKE marc-werks,    "Plant

          w_lgnum           LIKE mlgn-lgnum,    "Warehouse Number

          w_matnr           LIKE mara-matnr,    "Material Number Work Field

          w_error(1)        TYPE c,             "Error flag

          w_lenum(18)       TYPE c,             "SUID Work Field  DDSK907483

          w_vsolm(13)       TYPE c,             "Quantity Work Field

          w_letyp_flg(1)    TYPE c.             "Storage Unit Type Flag

     

    DATA: w_infile TYPE string.

     

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

    •                  I N T E R N A L   T A B L E S                       *

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

     

    • Internal table to hold good records to be saved in table ZWMINVDAT.

    DATA: BEGIN OF update_tab OCCURS 0.

            INCLUDE STRUCTURE zwminvdat.

    DATA: END OF update_tab.

     

    • Internal table to hold error records to be saved in table

    • ZWMINVDAT_ERR

    DATA: BEGIN OF err_tab OCCURS 0.

            INCLUDE STRUCTURE zwminvdat_err.

    DATA: END OF err_tab.

     

    • Internal table to hold the contents of the input file.

    DATA: BEGIN OF file_tab OCCURS 0,

           matnr     LIKE mara-matnr,         "Material Number

           lgpla     LIKE lagp-lgpla,         "Storage Bin

           vsolm(10) TYPE c,                  "Quantity

           lenum(20) TYPE c,                  "SUID Number

          END OF file_tab.

     

    START-OF-SELECTION.

     

      REFRESH file_tab.

      CLEAR   file_tab.

     

      TRANSLATE p_infile TO LOWER CASE.

     

      w_infile = p_infile.

     

    • Upload the data file into an internal table.

      CALL FUNCTION 'GUI_UPLOAD'

        EXPORTING

          filename                = w_infile

          filetype                = 'ASC'

          has_field_separator     = 'X'

        TABLES

          data_tab                = file_tab

        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 the data loaded ok, clear the error record processing table, get

    • some parameter ID values and save them for later use.

      IF sy-subrc EQ 0.

     

        REFRESH: err_tab, update_tab.                           "DDSK913039

        CLEAR:   err_tab, update_tab.                           "DDSK913039

     

        GET PARAMETER ID 'WRK' FIELD w_werks.

        GET PARAMETER ID 'LGN' FIELD w_lgnum.

     

    •   Get rid of any duplicate Material Number/SUID records that may have

    •   been uploaded.

        SORT file_tab BY lenum.

        DELETE ADJACENT DUPLICATES FROM file_tab COMPARING matnr lenum.

     

        LOOP AT file_tab.

     

          CLEAR w_error.

     

    •     Check the Material Number from the input file.

          PERFORM check_matnr.

     

    •     If a material number was found then check the Bin Number

    •     IF w_error IS INITIAL.                                  DDSK913067

          PERFORM check_bin.

     

    •       If a Bin was found then update the WM Inventory Table.

          IF w_error IS INITIAL.

            PERFORM update_inv_data.

            DELETE file_tab INDEX 1.

     

    •       A Bin was not found so delete the record in the input file

    •       internal table because the record has already been written to

    •       the error internal table.

          ELSE.

            DELETE file_tab INDEX 1.

          ENDIF.

     

    •     A Material Number was not found so delete the record in the input

    •     file internal table because the record has already been written to

    •     the error internal table.

    •     ELSE.                                                   DDSK913067

    •       DELETE file_tab INDEX 1.                              DDSK913067

    •     ENDIF.                                                  DDSK913067

        ENDLOOP.

     

        PERFORM process_records.                                "DDSK913039

        PERFORM process_errors.

     

    •   Initialize global variables.

        PERFORM init_all_vars.

     

    • Send out an error message if there was a problem with the input file.

      ELSE.

        MESSAGE     ID sy-msgid

                  TYPE sy-msgty

                NUMBER sy-msgno

                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

      ENDIF.

     

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

    •                        C H E C K _ M A T N R                         *

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

    FORM check_matnr.

     

      DATA: l_len      TYPE i,

            l_loop_ctr TYPE i.

     

      CLEAR: w_matnr, l_len, l_loop_ctr.

     

    • Convert the material number by deleting the dashes and adding the

    • leading zeroes.

      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

        EXPORTING

          input  = file_tab-matnr

        IMPORTING

          output = w_matnr

        EXCEPTIONS

          OTHERS = 1.

     

    • Try to get a record from table MARC for the material number and plant.

      SELECT SINGLE * FROM marc WHERE matnr EQ w_matnr

                                  AND werks EQ w_werks.

     

    • If a record was not found in MARC, format the SUID number, and move

    • the current record to the error internal table.

      IF sy-subrc NE 0.

        l_len = STRLEN( file_tab-lenum ).

     

        l_loop_ctr = 20 - l_len.

        DO l_loop_ctr TIMES.

          CONCATENATE '0' file_tab-lenum INTO file_tab-lenum.

        ENDDO.

     

        CLEAR err_tab.                                          "DDSK913075

        MOVE-CORRESPONDING file_tab TO err_tab.

        MOVE: syst-mandt TO err_tab-mandt,

              w_matnr    TO err_tab-matnr,

              'IP'       TO err_tab-letyp,                      "DDSK913004

              'X'        TO err_tab-matl.                       "DDSK913006

     

        APPEND err_tab.

        CLEAR  err_tab.

        MOVE   'X' TO w_error.

      ENDIF.

     

    ENDFORM.                    " CHECK_MATNR

     

     

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

    •                          C H E C K _ B I N                           *

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

    FORM check_bin.

     

      DATA: l_len      TYPE i,

            l_loop_ctr TYPE i.

     

      CLEAR: l_len, l_loop_ctr.

     

    • Try to get a record from table LAGP for the warehouse number and Bin.

      SELECT SINGLE * FROM lagp WHERE lgnum EQ w_lgnum

                                  AND lgpla EQ file_tab-lgpla.

     

    • If a record was not found in LAGP, format the SUID number, and move

    • the current record to the error internal table.

      IF sy-subrc NE 0.

     

        IF w_error IS INITIAL.                                  "DDSK913067

          CLEAR: w_matnr.

     

    •     Convert the material number by deleting the dashes and adding the

    •     leading zeroes.

          CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

            EXPORTING

              input  = file_tab-matnr

            IMPORTING

              output = w_matnr

            EXCEPTIONS

              OTHERS = 1.

     

          l_len = STRLEN( file_tab-lenum ).

     

          l_loop_ctr = 20 - l_len.

          DO l_loop_ctr TIMES.

            CONCATENATE '0' file_tab-lenum INTO file_tab-lenum.

          ENDDO.

     

          CLEAR err_tab.                                        "DDSK913075

          MOVE-CORRESPONDING file_tab TO err_tab.

          MOVE: syst-mandt TO err_tab-mandt,

                w_matnr    TO err_tab-matnr,

               'IP'       TO err_tab-letyp,                     "DDSK913004

               'X'        TO err_tab-bin.                       "DDSK913006

     

          APPEND err_tab.

          CLEAR  err_tab.

          MOVE   'X' TO w_error.

        ELSE.                                                   "DDSK913067

          READ TABLE err_tab WITH KEY lenum = file_tab-lenum.   "DDSK913067

          IF sy-subrc EQ 0.                                     "DDSK913067

            MOVE 'X' TO err_tab-bin.                            "DDSK913067

            MODIFY err_tab INDEX sy-tabix.                      "DDSK913067

          ENDIF.                                                "DDSK913067

        ENDIF.                                                  "DDSK913067

      ENDIF.

     

    ENDFORM.                    " CHECK_BIN

     

     

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

    •                    U P D A T E _ I N V _ D A T A                     *

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

     

    FORM update_inv_data.

     

      DATA: l_len      TYPE i,

            l_loop_ctr TYPE i.

     

    • REFRESH update_tab.                                         DDSK913039

      CLEAR:   l_len, l_loop_ctr, w_matnr.        "update_tab     DDSK913039

     

    • Convert the material number by deleting the dashes and adding the

    • leading zeroes.

      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

        EXPORTING

          input  = file_tab-matnr

        IMPORTING

          output = w_matnr

        EXCEPTIONS

          OTHERS = 1.

     

    • Format the SUID number, and move the current record to the update

    • internal table.

      l_len = STRLEN( file_tab-lenum ).

     

      l_loop_ctr = 20 - l_len.

      DO l_loop_ctr TIMES.

        CONCATENATE '0' file_tab-lenum INTO file_tab-lenum.

      ENDDO.

     

      MOVE: syst-mandt      TO update_tab-mandt,

            file_tab-lenum  TO update_tab-lenum,

            w_matnr         TO update_tab-matnr,

            file_tab-vsolm  TO update_tab-vsolm,

            file_tab-lgpla  TO update_tab-lgpla,

            'IP'            TO update_tab-letyp.                "DDSK913004

     

      APPEND update_tab.

      CLEAR  update_tab.                            "DDSK913004, DDSK913039

     

    ENDFORM.                    "UPDATE_INV_DATA

     

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

    •                    P R O C E S S _ E R  R O R S                      *

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

    FORM process_errors.

     

      DESCRIBE TABLE err_tab.

     

    • Save eny error records to table ZWMINVDAT_ERR

      IF sy-tfill GT 0.

        DELETE FROM zwminvdat_err.

        COMMIT WORK.

        INSERT  zwminvdat_err FROM TABLE err_tab.

        COMMIT WORK.

      ENDIF.

     

    ENDFORM.                    "process_errors

     

    • Begin DDSK913039

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

    •                    P R O C E S S _ R E C O R D S                     *

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

    FORM process_records.

     

      DESCRIBE TABLE update_tab.

     

    • Save eny good records to table ZWMINVDAT

      IF sy-tfill GT 0.

        DELETE FROM zwminvdat.

        COMMIT WORK.

        INSERT zwminvdat FROM TABLE update_tab.                 "DDSK913041

        COMMIT WORK.                                            "DDSK913041

      ENDIF.

    ENDFORM.                    "process_records

    • End   DDSK913039

     

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

    •                       I N I T _ A L L _ V A R S                      *

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

    FORM init_all_vars.

     

      CLEAR: w_werks,         "Plant

             w_lgnum,         "Warehouse Number

             w_matnr,         "Material Number Work Field

             w_error,         "Error flag

             w_lenum,         "SUID Number Work Field

             w_vsolm.         "Quantity Work Field

     

    ENDFORM.                    " INIT_ALL_VARS

  • Re: F4_FILENAME
    Srinivas Gummaluri
    Currently Being Moderated

    <a href="http://blog.csdn.net/zwxrain/archive/2007/08/09/1733490.aspx">see this link on how to use f4_filename</a>

     

    regards,

    srinivas

Actions