Quantcast
Channel: SCN : Document List - SAP ERP Financials
Viewing all articles
Browse latest Browse all 366

Upload Tool for Cutover Activity

$
0
0

Data Migration is a key aspect for any SAP Engagement. There are various tools available which enable seamless data migration in a short span of time. During my involvement in various engagements, this has been one of the pain areas. Often, most of us are at pain to use the various tools and have to be dependent.

The tool highlighted below helps to have a common tool that can be used to prepare data upload templates across various modules. This tool calls up a BDC Program in the background. A prerequisite for using this tool is the knowledge of recording a BDC and the basic functions in Excel.

 

The code for the same is:

 

REPORT ZR_PP_YSCTA7O.

 

PARAMETERS : DMODE TYPE C DEFAULT 'A',

             FNAME LIKE RLGRAP-FILENAME OBLIGATORY

                       DEFAULT 'c:\desktop\test\matmas.txt',

             TRANCODE(4) TYPE C OBLIGATORY DEFAULT 'MM01'.

DATA : FLEN TYPE I, FLEN2 TYPE I.

DATA : HASH VALUE '#', PERCNT VALUE '%', L_COMA VALUE ','.

DATA : TEMP1, TEMP2.

DATA PROG_TAG1 TYPE I VALUE 0.

DATA : PROG_NAME(50).

DATA : STR_FLD(50), STR_VAL(40).

DATA : HDR_LINE(5000),

       COMP_HDR_LINE(5000),

       HDR_LINE1(40),

       HDR_LINE2(5000),

       STR_LINE(5000),

       STR_LINE1(40),

       STR_LINE2(5000).

 

DATA : BEGIN OF MESSTAB OCCURS 0.

        INCLUDE STRUCTURE BDCMSGCOLL.

DATA : END OF MESSTAB.

 

DATA : BEGIN OF ITAB OCCURS 10,

       ITEXT(5000) TYPE C,

END OF ITAB.

 

DATA : BEGIN OF BDCDATA OCCURS 0.

        INCLUDE STRUCTURE BDCDATA.

DATA :END OF BDCDATA.

*----------- Possible entries button for Filename SEARCH --------------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.

  PERFORM GET_FILE CHANGING FNAME.

 

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD'

     EXPORTING

          CODEPAGE            = 'TEST'

          FILENAME            = FNAME

          FILETYPE            = 'DAT'

     IMPORTING

          FILELENGTH          = FLEN

     TABLES

          DATA_TAB            = ITAB

     EXCEPTIONS

          CONVERSION_ERROR    = 1

          FILE_OPEN_ERROR     = 2

          FILE_READ_ERROR     = 3

          INVALID_TABLE_WIDTH = 4

          INVALID_TYPE        = 5

          NO_BATCH            = 6

          UNKNOWN_ERROR       = 7

          OTHERS              = 8.

*perform create_group.

PERFORM GEN_BDC_DATA.

*---------------------------------------------------------------------*

*       FORM CREATE_GROUP                                             *

*---------------------------------------------------------------------*

*       ........                                                      *

*---------------------------------------------------------------------*

FORM CREATE_GROUP.

  CALL FUNCTION 'BDC_OPEN_GROUP'

       EXPORTING

            CLIENT              = SY-MANDT

            GROUP               = 'PPGroup'

            HOLDDATE            = SY-DATUM

            USER                = SY-UNAME

       EXCEPTIONS

            CLIENT_INVALID      = 1

            DESTINATION_INVALID = 2

            GROUP_INVALID       = 3

            GROUP_IS_LOCKED     = 4

            HOLDDATE_INVALID    = 5

            INTERNAL_ERROR      = 6

            QUEUE_ERROR         = 7

            RUNNING             = 8

            SYSTEM_LOCK_ERROR   = 9

            USER_INVALID        = 10

            OTHERS              = 11.

  WRITE :/ 'Function open_group status : ', SY-SUBRC.

 

  PERFORM GEN_BDC_DATA.

 

  CALL FUNCTION 'BDC_CLOSE_GROUP'.

  1. ENDFORM.

*---------------------------------------------------------------------*

*       FORM GEN_BDC_DATA                                             *

*---------------------------------------------------------------------*

*       ........                                                      *

*---------------------------------------------------------------------*

FORM GEN_BDC_DATA.

 

  LOOP AT ITAB.

    REFRESH BDCDATA.

    IF ITAB-ITEXT(1) EQ HASH.

      MOVE ITAB-ITEXT TO HDR_LINE.

    ELSEIF ITAB-ITEXT(1) EQ PERCNT.

      MOVE HDR_LINE TO COMP_HDR_LINE.

      MOVE ITAB-ITEXT TO STR_LINE.

      DO.

        IF STR_LINE(1) = '!'.

          EXIT.

        ENDIF.

        SPLIT COMP_HDR_LINE AT L_COMA INTO HDR_LINE1 HDR_LINE2.

        CLEAR COMP_HDR_LINE.

        MOVE HDR_LINE2 TO COMP_HDR_LINE.

        CLEAR HDR_LINE2.

 

        SPLIT STR_LINE AT L_COMA INTO STR_LINE1 STR_LINE2.

        CLEAR STR_LINE.

        MOVE STR_LINE2 TO STR_LINE.

        CLEAR STR_LINE2.

        FLEN = STRLEN( STR_LINE1 ).

        FLEN2 = FLEN - 1.

        IF STR_LINE1(1) EQ PERCNT.

          IF FLEN GT 1.

            MOVE STR_LINE1+1(FLEN2) TO PROG_NAME.

            CLEAR STR_LINE1.

            MOVE PROG_NAME TO STR_FLD.

            PROG_TAG1 = 1.

          ELSEIF FLEN EQ 1.

            CLEAR STR_LINE1.

            MOVE PROG_NAME TO STR_FLD.

            PROG_TAG1 = 1.

          ENDIF.

        ELSEIF PROG_TAG1 EQ 1.

          MOVE STR_LINE1 TO STR_VAL.

          PERFORM BDC_DYNPRT USING STR_FLD STR_VAL.

          CLEAR : STR_FLD, STR_VAL.

          PROG_TAG1 = 0.

        ELSE.

          PERFORM BDC_FIELD USING HDR_LINE1 STR_LINE1.

        ENDIF.

*     write :/ hdr_line1, '  ', str_line1.

        CLEAR : HDR_LINE1, STR_LINE1.

      ENDDO.

 

* perform pop_data.

CALL TRANSACTION TRANCODE USING BDCDATA MODE DMODE MESSAGES

                        INTO MESSTAB.

 

    ENDIF.

* Hash the following loop if not required.

   LOOP AT BDCDATA.

     WRITE :/ BDCDATA-PROGRAM, BDCDATA-DYNPRO, BDCDATA-DYNBEGIN,

           BDCDATA-FNAM, BDCDATA-FVAL.

   ENDLOOP.

  ENDLOOP.

  1. ENDFORM.

*---------------------------------------------------------------------*

*       FORM POP_DATA                                                 *

*---------------------------------------------------------------------*

*       ........                                                      *

*---------------------------------------------------------------------*

FORM POP_DATA.

  CALL FUNCTION 'BDC_INSERT'

       EXPORTING

            TCODE     = TRANCODE

       TABLES

            DYNPROTAB = BDCDATA

         EXCEPTIONS

              INTERNAL_ERROR = 1

              NOT_OPEN       = 2

              QUEUE_ERROR    = 3

              TCODE_INVALID  = 4

              OTHERS         = 5.

  WRITE :/ 'Function insert status :', SY-SUBRC.

  1. ENDFORM.

*---------------------------------------------------------------------*

*       FORM BDC_DYNPRT                                               *

*---------------------------------------------------------------------*

*       ........                                                      *

*---------------------------------------------------------------------*

*  -->  PROGRAM                                                       *

*  -->  DYNPRO                                                        *

*---------------------------------------------------------------------*

FORM BDC_DYNPRT USING PROGRAM DYNPRO.

  CLEAR BDCDATA.

*write :/ program, dynpro.

  BDCDATA-PROGRAM = PROGRAM.

  BDCDATA-DYNPRO = DYNPRO.

  BDCDATA-DYNBEGIN = 'X'.

  APPEND BDCDATA.

  1. ENDFORM.

*---------------------------------------------------------------------*

*       FORM BDC_FIELD                                                *

*---------------------------------------------------------------------*

*       ........                                                      *

*---------------------------------------------------------------------*

*  -->  FNAM                                                          *

*  -->  FVAL                                                          *

*---------------------------------------------------------------------*

FORM BDC_FIELD USING FNAM FVAL.

  CLEAR BDCDATA.

  BDCDATA-FNAM = FNAM.

  BDCDATA-FVAL = FVAL.

  APPEND BDCDATA.

  1. ENDFORM.

*&---------------------------------------------------------------------*

*&      Form  GET_FILE

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      <--P_FNAME  text

*----------------------------------------------------------------------*

form GET_FILE changing fname.

 

 

  CALL FUNCTION 'WS_FILENAME_GET'

       EXPORTING

            DEF_FILENAME     = '*.txt '

            DEF_PATH         = 'C:\'

            MASK             = ',*.txt,*.*.'

            MODE             = 'O'

          TITLE         = 'Open a Text(Tab delimited)(*.txt) file only'

       IMPORTING

            FILENAME         =  FNAME

       EXCEPTIONS

            INV_WINSYS       = 1

            NO_BATCH         = 2

            SELECTION_CANCEL = 3

            SELECTION_ERROR  = 4

            OTHERS           = 5.

  IF SY-SUBRC = 0.

    FNAME = FNAME.

  ENDIF.

ENDFORM.

 

 

Steps to execute the process:

1.      1.  Copy the code above and create a transaction for the same.For the custom program, create a new transaction code through SE93

 

PIC1.png

 

 

 

         

         2. Use the transaction code SHDB to create the recording

 

 

 

 

 

PIC1.png

 

PIC2.png

PIC3.png

PIC4.png

 

PIC5.png

 

 

PIC6.png

1.      3.  The next step is to create the excel template for the upload. After the recording has been done, allow system folder options to allow extensions for known file types.

PIC1.png

 

Now open the excel worksheet and make the below format

 

PIC2.png

PIC3.pngPIC4.png

PIC5.png

 

Now copy the text from the recording done earlier into the excel sheet

 

 

PIC1.png

PIC2.png

PIC3.png

Now go back to the recording in SHDB

 

 

PIC1.png

 

Now paste the information into the excel sheet again

 

 

 

PIC1.png

PIC2.png

 

Copy all the fields from the recording into the excel file. When a transaction is executed in SAP, it calls up multiple screen along with their variants. It is important to copy the recordings of all the screens into the excel sheet

 

 

PIC1.png

 

After all the data of recording has been transferred, please end the row with a “!”

 

 

 

PIC1.pngPIC2.png

 

PIC3.png

 

PIC4.png

 

 

Use the T Code ZBDC to upload the file in SAP

 

PIC1.png

 

When the transaction is executed, the document is created.

 

PIC2.png


Viewing all articles
Browse latest Browse all 366

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>