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

uploading the flat files..

hii...

what are the diffrent function modules available in SAP to upload the flat file?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 06:00 AM

    Hi,

    The following function modules are available

    GUI_UPLOAD

    WS_UPLOAD

    With regards

    K.Varadharjan

    Kindly Award points if it is useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 05:57 AM

    <b>gui_upload.</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 06:02 AM

    Hi vikram,

    <b>UPLOAD</b>--- upload a file from the presentation server (PC)

    <b>WS_UPLOAD</b>---- Load Files from the Presentation Server to Internal ABAP Tables.

    This is used upto SAP 4.6 version.

    <b>GUI_UPLOAD</b>------- Replaces WS_UPLOAD. Upoad file from presentation server to the app server. From 4.7 SAP version it is replaced.

    <b>ALSM_EXCEL_TO_INTERNAL_TABLE</b> : to upload data frm excel.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 06:38 AM

    Dear Vikram,

    Current Release for article: 4.6b This article describes creating a workstation upload to SAP. The <b>WS_UPLOAD</b> function replaces the old <b>GUI_UPLOAD</b>. GUI_UPLOAD should no longer be used.

    Upload a file from a workstation, or a "presentation server" as it is known in the SAP world, to an ABAP program is a relatively simple procedure requiring a call to the BAPI WS_UPLOAD. The BAPI processes the request and returns an internal table containing the uploaded file.

    Please go through the following code inorder to understand the usage of the Function Module --> <b>ALSM_EXCEL_TO_INTERNAL_TABLE</b>

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

    • D A T A D E C L A R A T I O N *

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

    TABLES: ANEP,

    BKPF.

    TYPES: BEGIN OF TY_TABDATA,

    MANDT LIKE SY-MANDT, " Client

    ZSLNUM LIKE ZSHIFTDEPN-ZSLNUM, " Serial Number

    ZASSET LIKE ZSHIFTDEPN-ZASSET, " Original asset that was transferred

    ZYEAR LIKE ZSHIFTDEPN-ZYEAR, " Fiscal Year

    ZPERIOD LIKE ZSHIFTDEPN-ZPERIOD, " Fiscal Period

    ZSHIFT1 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 1

    ZSHIFT2 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 2

    ZSHIFT3 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 3

    END OF TY_TABDATA.

    *----


    • Declaration of the Internal Table with Header Line comprising of the uploaded data.

    *----


    DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.

    INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data

    DATA: END OF IT_FILE_UPLOAD.

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

    • S E L E C T I O N - S C R E E N *

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

    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,

    BEGIN OF BLOCK B2 WITH FRAME.

    PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.

    SELECTION-SCREEN: END OF BLOCK B2,

    END OF BLOCK B1.

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

    • E V E N T : AT S E L E C T I O N - S C R E E N *

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

    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.

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

    • E V E N T : S T A R T - O F - S E L E C T I O N *

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

    START-OF-SELECTION.

    • --------------------------------------

    • Upload Excel file into Internal Table.

    • --------------------------------------

    PERFORM UPLOAD_EXCEL_FILE.

    • -------------------------------------------------------

    • Organize the uploaded data into another Internal Table.

    • -------------------------------------------------------

    PERFORM ORGANIZE_UPLOADED_DATA.

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

    • E V E N T : E N D - O F - S E L E C T I O N *

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

    END-OF-SELECTION.

    &----


    *& Form UPLOAD_EXCEL_FILE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM UPLOAD_EXCEL_FILE .

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    FILENAME = P_FNAME

    I_BEGIN_COL = 1

    I_BEGIN_ROW = 3

    I_END_COL = 7

    I_END_ROW = 32000

    TABLES

    INTERN = IT_FILE_UPLOAD

    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. " UPLOAD_EXCEL_FILE

    &----


    *& Form ORGANIZE_UPLOADED_DATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM ORGANIZE_UPLOADED_DATA .

    SORT IT_FILE_UPLOAD BY ROW

    COL.

    LOOP AT IT_FILE_UPLOAD.

    CASE IT_FILE_UPLOAD-COL.

    • ....................................................

    WHEN 1.

    WA_TABDATA-ZSLNUM = IT_FILE_UPLOAD-VALUE.

    WHEN 2.

    WA_TABDATA-ZASSET = IT_FILE_UPLOAD-VALUE.

    WHEN 3.

    WA_TABDATA-ZYEAR = IT_FILE_UPLOAD-VALUE.

    WHEN 4.

    WA_TABDATA-ZPERIOD = IT_FILE_UPLOAD-VALUE.

    WHEN 5.

    WA_TABDATA-ZSHIFT1 = IT_FILE_UPLOAD-VALUE.

    WHEN 6.

    WA_TABDATA-ZSHIFT2 = IT_FILE_UPLOAD-VALUE.

    WHEN 7.

    WA_TABDATA-ZSHIFT3 = IT_FILE_UPLOAD-VALUE.

    • ....................................................

    ENDCASE.

    AT END OF ROW.

    WA_TABDATA-MANDT = SY-MANDT.

    APPEND WA_TABDATA TO IT_TABDATA.

    CLEAR: WA_TABDATA.

    ENDAT.

    ENDLOOP.

    ENDFORM. " ORGANIZE_UPLOADED_DATA

    In the subroutine --> ORGANIZE_UPLOADED_DATA, data are organized as per the structure declared above.

    Regards,

    Abir

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

    • Don't forget to award points *

                                                                      Add a comment
                                                                      10|10000 characters needed characters exceeded

                                                                    Before answering

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

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