Register Login

Function Modules That Can Be Used To Upload XML File From Application Server & File Operations On Application Server.

Updated May 18, 2018

  1. RZL_READ_DIR : Read directories of an application server
     

    v_map_dir1 = 'D:OUTPUTSuccess'.
     

    CALL FUNCTION 'RZL_READ_DIR'

        EXPORTING

    *     FROMLINE             = 0

          name                 = v_map_dir

    *     NRLINES              = 50

    *     SRVNAME              = ' '

        TABLES

          file_tbl             = it_file

    *   EXCEPTIONS

    *     ARGUMENT_ERROR       = 1

    *     NOT_FOUND            = 2

    *     SEND_ERROR           = 3

    *     SYSTEM_FAILURE       = 4

    *     OTHERS               = 5         .

      IF sy-subrc <> 0.

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

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

      ENDIF.


    v_map_dir contains the folder path on the application server.

    All the files in Success folder will be returned in the internal table it_file.

    FMCT_DELETE_UNIXFILE : To delete the file on the application server
     
    * Internal table to store file names

    DATA:  isalfldir LIKE sdokpath OCCURS 0 WITH HEADER LINE.


    concatenate 'D:INPUT' isalfldir-pathname+0(25) into v_src_filename.


            CALL FUNCTION 'FMCT_DELETE_UNIXFILE'

             EXPORTING

               UX_FILE       = v_src_filename

             EXCEPTIONS

               NO_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.
      

    3.  SCMS_STRING_TO_XSTRING : To convert string data to xstring
     

    DATA: BEGIN OF xmlparse OCCURS 0,

              xmlcontent TYPE string,

            END OF xmlparse.

    DATA: xmldata TYPE xstring.
     

    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

         EXPORTING

           text           = xmlparse-xmlcontent

    *      MIMETYPE       = ' '

    *      ENCODING       =

         IMPORTING

           buffer         = xmldata

         EXCEPTIONS

           failed         = 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.
     

    4.  SMUM_XML_PARSE : To get the data into internal table xml_table
     

    DATA: xml_table TYPE smum_xmltb OCCURS 0,

            return TYPE bapiret2 OCCURS 0.

      data: wa_return like line of return.


    CALL FUNCTION 'SMUM_XML_PARSE'

         EXPORTING

           xml_input       = xmldata

         TABLES

           xml_table       = xml_table

           return          = return
     

    To move the file from one folder on application server to another


    5.  'PFL_CHECK_OS_FILE_EXISTENCE


    DATA: v_exist.

      CLEAR v_exist.

      CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'

        EXPORTING

          fully_qualified_filename = v_src_filename

        IMPORTING

          file_exists              = v_exist.

     
    6.  'PFL_COPY_OS_FILE'

       IF v_exist EQ 'X'.

        CALL FUNCTION 'PFL_COPY_OS_FILE'

          EXPORTING

            source_file_name = p_v_src_filename

            target_file_name = p_v_dst_filename.

        IF sy-subrc EQ 0.

    Thanks & Regards,
    Uttam


×