28 Replies Latest reply: Mar 30, 2012 1:23 PM by anurag mutyala RSS

BAPI_SALESORDER_CREATEFROMDAT2 - Item long text

anurag mutyala
Currently Being Moderated

Dear Friends,

i am uploading some details along with item text using bapi_salesorder_createfromdat2.

all the data is uploaded perfetly except the item long text.

my code snipped for uploading long text is..

   *Item Long Text
          WA_TEXT-ITM_NUMBER  = ITEM_NUM.
          WA_TEXT-TEXT_ID     = 'Z001'.
          WA_TEXT-LANGU       = 'E'.

          WA_TEXT-TEXT_LINE   = WA_SUB-LONG_TEXT.
          APPEND WA_TEXT TO IT_TEXT.
          CLEAR WA_TEXT.

can'T  anyone help me plz......?

  • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
    nabheet madan
    Currently Being Moderated

    For long text you can use SAVE_TEXT  separately.  Where are you passing text object in above case.

     

    Nabheet

    • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
      anurag mutyala
      Currently Being Moderated

      when do i call save_text.. after bapi commit ?

      can u please explain elobarately.

      • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
        nabheet madan
        Currently Being Moderated

        Once the sales order is created.

         

        Thanks

        Nabheet

        • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
          anurag mutyala
          Currently Being Moderated

          so i have to call save_text first and then bapi_trasaction_commit. ?

          Actually i am getting the data from excel sheet. From file i am moving that data in one internal table.

          i have the text item wise. How do i pass the text per each item in one header data.

          Do i need to pass the data for long text to bapi also...?

          can anyone help me plz.

        • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
          anurag mutyala
          Currently Being Moderated

          can u plz help me

          • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
            Kumar Gaurav
            Currently Being Moderated

            You will have to call the save_text after each line item. I am assuming the bapi is getting called in a loop. After bapi call and  before end of loop, you should loop at each line item and call the FM SAVE_TEXT.

            Note : for each line item you need to create one long text

            The Data you need to pass to SAVE_TEXT should be similar to the below screen shotsales ord Item text.JPG

            Text Name = concatenation of sales order and sales order item

            text id = 00001 ( I am assuming your updating the sales text given on the texts tab of the item display)

            rest details same as above.

             

            The text you need to update must be passed to    LINES table of the FM interface.  AND Yes you need a commit work to save the long text

            • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
              anurag mutyala
              Currently Being Moderated

              Dear Kumar,

              i Tried what u said.. still it is not updating..

              heer my code...

              loop at it_main into wa_main.

              ---

                   loop at it_sub into wa_sub where contrno = wa_main-contrno.

                        --------

                 endloop.   "for it_sub

                        call function 'BAPI_SALESORDER_CREATEFROMDAT2'

                  -----------------------------------

                        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                        EXPORTING
                          WAIT = 'X'.

              **Upload Item Long Text
                      clear wa_sub.
                      LOOP AT IT_SUB INTO WA_SUB WHERE CONTRNO = WA_MAIN-CONTRNO.

                        DATA THEADER LIKE THEAD.
                        data nheader like thead.
                        DATA : t_TEXT LIKE TABLE OF TLINE,
                               w_text like line of t_text.
                       data : function(3) type c.

                        DATA : ITEM_NUM1 TYPE VBAP-POSNR.
                        ITEM_NUM1 = 10 * SY-TABIX.

                        CONCATENATE WA_VBELN ITEM_NUM1 INTO THEADER-TDNAME.
                        THEADER-TDOBJECT =  'VBBP'.
                        THEADER-TDID     = 'Z001'.
                        THEADER-TDSPRAS  = SY-LANGU. "'EN'.

                        w_text-tdline = wa_sub-long_text.
                       append w_text to t_text.

                              CALL FUNCTION 'SAVE_TEXT'
                              EXPORTING
                                CLIENT                = SY-MANDT
                                HEADER                = theader
                                INSERT                = 'X'
              *                 SAVEMODE_DIRECT       = ' '
              *                 OWNER_SPECIFIED       = ' '
              *                 LOCAL_CAT             = ' '
                             IMPORTING
                               FUNCTION              = function
                               NEWHEADER             = nheader
                              TABLES
                                LINES                 = t_TEXT
                             EXCEPTIONS
                               ID                    = 1
                               LANGUAGE              = 2
                               NAME                  = 3
                               OBJECT                = 4
                               OTHERS                = 5
                                      .
                            IF SY-SUBRC = 0.
                      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                        EXPORTING
                          WAIT = 'X'.

                        endif.
                      ENDLOOP.

               

              *** Kindly help me.

              • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
                Pranav Mandelia
                Currently Being Moderated

                Hi Anurag,

                As directed by Nabheet & Kumar you've done it right, just forgot to add theader-tdname = Sales Order Number from the BAPI to SAVE_TEXT.

                Regards,

                Pranav.

              • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
                Kumar Gaurav
                Currently Being Moderated

                After calling the bapi  get the sales document from export parameter say (l_v_vbeln)

                Loop at table which you have passed ORDER_ITEMS_IN parameter of the BAPI and get the text name. properly.check the bold text. TDID shoud be 0001

                clear wa_sub.
                        LOOP AT IT_ORDER_ITEMS_IN INTO WA_ ORDER_ITEMS_IN .

                 

                          DATA THEADER LIKE THEAD.
                          data nheader like thead.
                          DATA : t_TEXT LIKE TABLE OF TLINE,
                                 w_text like line of t_text.
                         data : function(3) type c.

                 

                          DATA : ITEM_NUM1 TYPE VBAP-POSNR.
                     

                 

                          CONCATENATE l_v_vbeln WA_ ORDER_ITEMS_IN-ITM_NUMBER  INTO THEADER-TDNAME.
                          THEADER-TDOBJECT =  'VBBP'.
                          THEADER-TDID     = '0001'.
                          THEADER-TDSPRAS  = SY-LANGU. "'EN'.

                 

                          w_text-TDFORMAT  = '*'.

                w_text-tdline = wa_sub-long_text.
                         append w_text to t_text.

                 

                                CALL FUNCTION 'SAVE_TEXT'
                                EXPORTING
                                  CLIENT                = SY-MANDT
                                  HEADER                = theader
                                  INSERT                = 'X'
                *                 SAVEMODE_DIRECT       = ' '
                *                 OWNER_SPECIFIED       = ' '
                *                 LOCAL_CAT             = ' '
                               IMPORTING
                                 FUNCTION              = function
                                 NEWHEADER             = nheader
                                TABLES
                                  LINES                 = t_TEXT
                               EXCEPTIONS
                                 ID                    = 1
                                 LANGUAGE              = 2
                                 NAME                  = 3
                                 OBJECT                = 4
                                 OTHERS                = 5
                                        .
                              IF SY-SUBRC <> 0.
                        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                          EXPORTING
                            WAIT = 'X'.

                          endif.
                        ENDLOOP.

  • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
    Vinit Joshi
    Currently Being Moderated

    Hello,

    After SAVE_TEXT , donot use BAPI TRANSACTION COMIIT.

    Use COMMIT_TEXT.

    Text modules can be independently updated. Make sure you pass correct Object name, ID as suggested in previous posts.

  • Re: BAPI_SALESORDER_CREATEFROMDAT2 - Item long text
    Madhu Vadlamani
    Currently Being Moderated

    Hi Anurag,

    You can try like this.

    WA_TEXT-ITM_NUMBER = '000010'.

    WA_TEXT-LANGU    = 'E'.

    WA_TEXT-TEXT_LINE = 'HELLO SALES ORDER ITEM TEXT SAP ' .

    WA_TEXT-TEXT_ID   = '0001'.

    WA_TEXT-FUNCTION = '001'.

    INSERT WA_TEXT INTO TABLE TAB_TEXT.

     

    Regards,

    Madhu.

Actions