Skip to Content
avatar image
Former Member

SAVE_TEXT problem

Hello All,

I am copying text from sales order and inserting into the production order.

I have used read_text, save_text and commit text.

In the debuggin i can see all the data getting populated, even iam getting sy-subrc = 0 in the save_text FM. <b>However text is not copied into the production order.</b>

Also i have a entry in STXH table.

I have posted my code for your reference

FORM ADD_LONG_TEXT1.

DATA: ID LIKE THEAD-TDID VALUE 'KOPF',

LANGUAGE LIKE THEAD-TDSPRAS,

NAME LIKE THEAD-TDNAME,

OBJECT LIKE THEAD-TDOBJECT VALUE 'AUFK'.

DATA: TLINES LIKE TLINE OCCURS 0 WITH HEADER LINE.

DATA: IT_THEAD LIKE THEAD OCCURS 0 WITH HEADER LINE.

*Prepare text criteria

CONCATENATE SY-MANDT txt-aufnr INTO NAME.

LANGUAGE = SY-LANGU.

*Begin of insert

MOVE id TO IT_THEAD-TDID.

MOVE language to IT_THEAD-TDSPRAS.

MOVE NAME to IT_THEAD-TDNAME.

MOVE OBJECT to IT_THEAD-TDOBJECT.

append it_thead.

*clear it_thead.

*End of insert

*First read text for existing data

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = ID

LANGUAGE = LANGUAGE

NAME = NAME

OBJECT = OBJECT

TABLES

LINES = TLINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

*Append/Insert new text data

LOOP AT txt-tline INTO wa_bdc.

CLEAR TLINES.

TLINES-TDFORMAT = '*'.

TLINES-TDLINE = wa_bdc-tdline.

APPEND TLINES.

ENDLOOP.

  • Secondly append new text data to existing data

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = it_thead

INSERT = ' '

SAVEMODE_DIRECT = 'X'

    • OWNER_SPECIFIED = ' '

    • LOCAL_CAT = ' '

    • IMPORTING

    • FUNCTION =

    • NEWHEADER =

    TABLES

    LINES = TLINES

    EXCEPTIONS

    ID = 1

    LANGUAGE = 2

    NAME = 3

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

    CALL FUNCTION 'COMMIT_TEXT'

      • EXPORTING

      • OBJECT = OBJECT

      • NAME = NAME

      • ID = ID

      • LANGUAGE = LANGUAGE

      • SAVEMODE_DIRECT = 'X'

      • KEEP = ' '

      • LOCAL_CAT = ' '

      • IMPORTING

      • COMMIT_COUNT =

      • TABLES

      • T_OBJECT =

      • T_NAME =

      • T_ID =

      • T_LANGUAGE =

      .

      ENDFORM. "ADD_LONG_TEXT

      Add comment
      10|10000 characters needed characters exceeded

      • Get RSS Feed

      10 Answers

      • Best Answer
        avatar image
        Former Member
        May 15, 2007 at 05:30 PM

        Hi,

        Check this sample code..

        It is working for me..

        
        PARAMETERS: p_aufnr TYPE aufk-aufnr.
        
        DATA: thead LIKE  thead.
        DATA: tline LIKE  tline OCCURS 0 WITH HEADER LINE.
        
        * initial data.
        thead-tdobject = 'AUFK'.
        thead-tdid     = 'KOPF'.
        thead-tdspras  = sy-langu.
        thead-tdname   = p_aufnr.
        
        * Lines
        tline-tdformat = '*'.
        tline-tdline   = 'Test data'.
        APPEND tline.
        
        CALL FUNCTION 'SAVE_TEXT'
             EXPORTING
                  header          = thead
                  savemode_direct = 'X'
             TABLES
                  lines           = tline
             EXCEPTIONS
                  id              = 1
                  language        = 2
                  name            = 3
                  object          = 4
                  OTHERS          = 5.
        IF sy-subrc = 0.
          WRITE: / 'Successful'.
          COMMIT WORK.
        ENDIF.
        

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi,

          Fine, just copied your code and wrote a test program, i too get sussecful message. However its not display in the co02 tcode in the long text tabstrip.

          Did you got that TEST DATA in your long text tab??

          Regards,

          Senthil

      • avatar image
        Former Member
        May 15, 2007 at 08:11 PM

        Hi,

        Make sure the text ID is correct..

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi,

          Found the problem.

          in CO02, input a production order number and in the next screen click create long text button in the top, input some text come back now you can see the text in the long text tabstrip, save, back.

          Now use save_text FM, use tline-tdline = 'Test data' which is different text from the one you entered in the transaction long text. Now use commit_text. Execute your program, the program text is replaced in the Long text and now it is visible in the tcode.

          The table AUFK has a field LTEXT which is long text indicator has to be set 'E' then it is coming as change long text for a particular order number, so now our code works fine, which is replacing the text in the code.

          Now i need your help.

          I dont want to direct update the table like this.

          UPDATE aufk SET ltext = 'E' WHERE aufnr = P_AUFNR.

          So for this please tell me a better way to handle this. Coz for a every new production order this will become a problem.

          Regards,

          Senthil

      • avatar image
        Former Member
        May 15, 2007 at 04:30 PM
        INSERT = ' '

        Should be...

        <b>INSERT = 'X'</b>

        Greetings,

        Blag.

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi Alvaro,

          I am getting sy-subrc = 5. if i put INSERT = 'X'.

          Error:

          I/O error for text AUFK 31000010010534 KOPF EN

      • avatar image
        Former Member
        May 15, 2007 at 04:32 PM

        Hi,

        Where are you changing the IT_THEAD-TDNAME with the production order number before calling the SAVE_TEXT FM??

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi Naren,

          This piece of code

          CONCATENATE SY-MANDT txt-aufnr INTO NAME.

          LANGUAGE = SY-LANGU.

          *Begin of insert

          MOVE id TO IT_THEAD-TDID.

          MOVE language to IT_THEAD-TDSPRAS.

          MOVE NAME to IT_THEAD-TDNAME.

          MOVE OBJECT to IT_THEAD-TDOBJECT.

          append it_thead.

          As this is in a loop, the txt-aufnr will change. Kindly help.

          Regards,

          Senthil

      • avatar image
        Former Member
        May 15, 2007 at 04:41 PM

        Hi,

        Is the field txt-aufnr is having leading zeroes to max the length of the field..

        Ex..

        If the field length is 12 and the value is 1234567890...

        You should pass 001234567890

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Yes in the debugg mode its the same length txt-aufnr 000100010534. I have tried with creat_text also but i cannot the text in production order.

      • avatar image
        Former Member
        May 15, 2007 at 04:54 PM

        Hi,

        Where are you calling this piece of code..Is it in a user exit??Is it in UPDATE TASK??

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi,

          This is not a user exit, iam not sure about the update task.

          It is a normal report program, have to copy the sales text to prod order and mark the user status check for TXTU .

          This piece of code.

          SELECT SINGLE matnr INTO i_matnr FROM vbap

          WHERE vbeln = afpo-kdauf AND posnr = afpo-kdpos.

          SELECT SINGLE mtart INTO i_mtart FROM mara

          WHERE matnr = i_matnr-matnr.

          IF i_mtart-mtart NE 'ZPPG'. " or i_mtart-mtart NE 'HALB'.

          IF txt-t_user CS 'TXTU'.

          ELSE.

          • If the status was changed write out the Order and Date.

          PERFORM ADD_LONG_TEXT1.

          IF sy-subrc = 0.

          READ TABLE GT_STATUS WITH KEY TXT04 = 'TXTU'.

          IF SY-SUBRC = 0.

          PERFORM UPDATE_USER_STATUS

          USING txt-aufnr GT_STATUS-ESTAT ''. "D01K956913+

          ENDIF.

          WRITE: / txt-aufnr.

          ELSE.

          FORMAT COLOR COL_NEGATIVE.

          WRITE: / txt-aufnr.

          FORMAT COLOR OFF.

          ENDIF.

          ENDIF.

      • avatar image
        Former Member
        May 15, 2007 at 05:02 PM

        Hi,

        Ok..Got it..

        Try this..

        Give COMMIT WORK ..After the COMMIT_TEXT function module..

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

      • avatar image
        Former Member
        May 15, 2007 at 05:12 PM

        Hi,

        Go to the table TTXOB..

        Give the object..

        Check the value in the field TDSAVEMODE...

        Also try passing the values to the COMMIT_TEXT Fm also..

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi Naren,

          Thanks for your help so far, however i didnot get the problem. Will check with my functional if anything is missing. In the mean time if you got some other idea plz post.

          Regards,

          Senthil

      • avatar image
        Former Member
        May 15, 2007 at 07:23 PM

        Hi,

        No..I checked using the READ_TEXT FM..

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded

        • Former Member

          Hi Naren,

          Yes it is working for me too using READ_TEXT.

          However it is not showing in the tcode, didnot know what to do.

          Regds,

          Senthil

      • avatar image
        Former Member
        May 15, 2007 at 08:48 PM

        Hi,

        Very good...

        You can use a BDC for transaction CO02 to update the field..

        I am not sure of any BAPI or FM..

        Thanks,

        Naren

        Add comment
        10|10000 characters needed characters exceeded