Uploading Material Master Long Text (Basic data text, Inspection text, Internal comment)

By Teja

This program could be used to upload the material master long text (Basic data text, inspection text, internal comment). Following is the screenshot from the transaction MM02.

 

We can achieve this functionality by using the Function Module ‘CREATE_TEXT’. 

Please note that if the long text already exists, then it is overwritten in this case. 

REPORT ZMM_INSERT_LONGTEXT.
*Internal table to hold long text...
DATA:
  BEGIN OF T_UPLOAD OCCURS 0,
    MATNR LIKE MARA-MATNR,             " Material number
    ID(2) TYPE C,                      " Identification
    LTEXT LIKE TLINE-TDLINE,           " Long text
  END OF T_UPLOAD,
*Internal table to hold long text....
  T_LINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA:
   W_GRUN LIKE THEAD-TDID ,            " To hold id
   W_OBJECT LIKE THEAD-TDOBJECT VALUE 'MATERIAL',
                                       " To hold object id
   LV_VALUE(70).                       " Value to hold material number
START-OF-SELECTION.
* This perform is used to upload the file
  PERFORM UPLOAD_FILE.
* This perform is used to place the text in MM02 transaction
  PERFORM PLACE_LONGTEXT.
*&---------------------------------------------------------------------*
*&      Form  create_text
*&---------------------------------------------------------------------*
*  This routine used to create text in MM02 transaction
*----------------------------------------------------------------------*
*  Passed the parameter w_grun to P_C_GRUN
*                 and lv_value to P_LV_VALUE
*----------------------------------------------------------------------*
FORM CREATE_TEXT  USING    P_C_GRUN
                           P_LV_VALUE.
  DATA:
    L_ID LIKE THEAD-TDID,
    L_NAME(70).
  MOVE : P_C_GRUN TO L_ID,
         P_LV_VALUE TO L_NAME.
  CALL FUNCTION 'CREATE_TEXT'
       EXPORTING
         FID               = L_ID
         FLANGUAGE         = SY-LANGU
         FNAME             = L_NAME
         FOBJECT           = W_OBJECT
*      SAVE_DIRECT       = 'X'
*      FFORMAT           = '*'
       TABLES
         FLINES            = T_LINE
      EXCEPTIONS
        NO_INIT           = 1
        NO_SAVE           = 2
        OTHERS            = 3
               .
  IF SY-SUBRC <> 0.
    CLEAR LV_VALUE.
  ELSE.
    DELETE T_LINE INDEX 1.
  ENDIF.
ENDFORM.                    " create_text
*&---------------------------------------------------------------------*
*&      Form  upload_file
*&---------------------------------------------------------------------*
*  This routine is used to upload file
*----------------------------------------------------------------------*
*  No interface parameters are passed
*----------------------------------------------------------------------*
FORM UPLOAD_FILE .
  CALL FUNCTION 'UPLOAD'
   EXPORTING
*     CODEPAGE                      = ' '
*     FILENAME                      = ' '
      FILETYPE                      = 'DAT'
*     ITEM                          = ' '
*     FILEMASK_MASK                 = ' '
*     FILEMASK_TEXT                 = ' '
*     FILETYPE_NO_CHANGE            = ' '
*     FILEMASK_ALL                  = ' '
*     FILETYPE_NO_SHOW              = ' '
*     LINE_EXIT                     = ' '
*     USER_FORM                     = ' '
*     USER_PROG                     = ' '
*     SILENT                        = 'S'
*   IMPORTING
*     FILESIZE                      =
*     CANCEL                        =
*     ACT_FILENAME                  =
*     ACT_FILETYPE                  =
    TABLES
      DATA_TAB                      = T_UPLOAD
     EXCEPTIONS
       CONVERSION_ERROR              = 1
       INVALID_TABLE_WIDTH           = 2
       INVALID_TYPE                  = 3
       NO_BATCH                      = 4
       UNKNOWN_ERROR                 = 5
       GUI_REFUSE_FILETRANSFER       = 6
       OTHERS                        = 7
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  SORT T_UPLOAD BY MATNR ID.
ENDFORM.                    " upload_file
*&---------------------------------------------------------------------*
*&      Form  place_longtext
*&---------------------------------------------------------------------*
*  This routine places the text in MM02 transaction
*----------------------------------------------------------------------*
*  No interface parameters are passed
*----------------------------------------------------------------------*
FORM PLACE_LONGTEXT .
  LOOP AT T_UPLOAD.
    T_LINE-TDFORMAT = 'ST'.
    T_LINE-TDLINE = T_UPLOAD-LTEXT.
    APPEND T_LINE.
    IF T_UPLOAD-ID EQ 'BT'.
      MOVE T_UPLOAD-MATNR TO LV_VALUE.
      MOVE 'GRUN' TO W_GRUN.                   "Test ID for Basic data text
      PERFORM CREATE_TEXT USING W_GRUN LV_VALUE.
    ENDIF.
    IF T_UPLOAD-ID EQ 'IT'.
      CLEAR W_GRUN.
      MOVE T_UPLOAD-MATNR TO LV_VALUE.
      MOVE 'PRUE' TO W_GRUN.                      "Test ID for Inspection text
      PERFORM CREATE_TEXT USING W_GRUN LV_VALUE.
    ENDIF.
    IF T_UPLOAD-ID EQ 'IC'.
      CLEAR W_GRUN.
      MOVE : T_UPLOAD-MATNR TO LV_VALUE,
             'IVER' TO W_GRUN.                     
                                                  "Test ID for Internal comment
      PERFORM CREATE_TEXT USING W_GRUN LV_VALUE.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " place_longtext

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image