Skip to Content
avatar image
Former Member

How to change long text of material

Dear Abappers,

I want to change long text of about 12,000 materials using upload by excel data.

How can I do it. ? I have searched on SCN but no proper solution found.

Regards,

Aneel

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 06, 2017 at 11:10 AM
    REPORT ZTEST_CREATE.
    
      DATA: p_orden TYPE aufk-aufnr,
      p_tdname TYPE thead-tdname,
      p_tdid TYPE thead-tdid,
      p_tdobject TYPE thead-tdobject,
      p_header TYPE thead,
      it_tline TYPE STANDARD TABLE OF tline
      WITH HEADER LINE,
      p_function.
    DATA : IT_FILE  LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    DATA FILE_PATH LIKE  RLGRAP-FILENAME.
    TYPES : BEGIN OF  SBU_UPLOAD ,
    matnr  type  matnr,
      MAKTG  TYPE MAKTG,
    
    END OF SBU_UPLOAD .
    DATA TBU_UPLOAD  TYPE STANDARD TABLE OF SBU_UPLOAD  WITH HEADER LINE.
    data vmatnr type matnr.
    
    CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'FILE_LOC' "Here file_LOC is the text Element name on Screen.
        IMPORTING
          file_name  = FILE_PATH.
    "In FILE_PATH you get the excel file path , ehich you want to upload in Internal table ex: E:\Prem\Premral_details.xls' and we pass this file name to the following function Module which Return back the Internal table of its own Format ."
     CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME                = FILE_PATH
          I_BEGIN_COL             = '1'
          I_BEGIN_ROW             = '2'
          I_END_COL               = '2'
          I_END_ROW               = '30000'
        TABLES
          INTERN                  = IT_FILE
        EXCEPTIONS
          INCONSISTENT_PARAMETERS = 1
          UPLOAD_OLE              = 2
          OTHERS                  = 3.
      IF SY-SUBRC NE SPACE.
    *leave PROGRAM.
      ENDIF.
    " Now I use the following Logic to convert that IT_FILE table  into our own table format."
    IF IT_FILE[]  IS  INITIAL.
      EXIT.
    ENDIF.
    
    
      LOOP AT IT_FILE.
        CASE IT_FILE-COL.
          WHEN '0001'.
            MOVE IT_FILE-VALUE TO TBU_UPLOAD-MATNR.
          WHEN '0002'.
            MOVE IT_FILE-VALUE TO TBU_UPLOAD-MAKTG.
    
    
        ENDCASE.
        AT END OF ROW.
     "At end of row TBU_UPLOAD is updated with the desired value i.e
    *When Row Column in table one converted  from 1 to 2 , the first column in Table 2 is inserted. Which is the required format of us . "
          APPEND TBU_UPLOAD.
          CLEAR TBU_UPLOAD.
        ENDAT.
    *       APPEND TBU_UPLOAD.
      ENDLOOP.
    
    
    LOOP   AT  TBU_UPLOAD.
    CLEAR it_tline[].
    
      it_tline-tdline =  TBU_UPLOAD-MAKTG .   "'02 THOUSAND1  ANEEL 11WWWWWWWWWWWW'.
      APPEND it_tline.
    
    
    vmatnr =  TBU_UPLOAD-MATNR." '14000000001574'.
    UNPACK  vmatnr   to  vmatnr.
    p_tdname = vmatnr.
    
    
      CALL FUNCTION 'CREATE_TEXT'
           EXPORTING
                fid         =  'GRUN'"p_tdid
                flanguage   = sy-langu
                fname       =    p_tdname
                fobject     = 'MATERIAL'
                save_direct = 'X'
                fformat     = '*'
           TABLES
                flines      = it_tline
           EXCEPTIONS
                no_init     = 1
                no_save     = 2
                OTHERS      = 3.
    COMMIT  WORK  AND WAIT.
    ENDLOOP.
        MESSAGE  'Done!!'  TYPE 'I'.
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 06, 2017 at 07:10 AM

    Long texts can be accessed using function modules READ_TEXT and SAVE_TEXT. Various objects can have long texts including sales and purchase order headers and items, materials, production orders etc etc and this is defined by the parameter TdObject. For a material it is 'MATERIAL'.

    Within each object are various text types. For materials there are:

    MATERIAL     BEST TX Purchase order text
    MATERIAL     GRUN TX Basic data text
    MATERIAL     IVER TX Internal note
    MATERIAL     PRUE TX Inspection text

    This is specified in TDID.

    You would load your excel spreadsheet using whichever method you require, loop around the table, populate the various parameters for the save_text function module and then call that module, not forgetting to commit work.

    As for searching google gives an SDN blog in the second result.

    Rich

    Add comment
    10|10000 characters needed characters exceeded