Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_SALESORDER_CREATEFROMDAT2 - Item long text

Former Member
0 Likes
6,626

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......?

1 ACCEPTED SOLUTION
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
5,453

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

Nabheet

28 REPLIES 28
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
5,454

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

Nabheet

Read only

0 Likes
5,453

when do i call save_text.. after bapi commit ?

can u please explain elobarately.

Read only

0 Likes
5,453

Once the sales order is created.

Thanks

Nabheet

Read only

0 Likes
5,453

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.

Read only

0 Likes
5,453

can u plz help me

Read only

0 Likes
5,453

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 shot

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

Read only

0 Likes
5,453

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.

Read only

0 Likes
5,453

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.

Read only

0 Likes
5,453

Dear Pranav,

I passed that valuea also.. but it is not getting updated.

as suggested by kumar... i passed so num & item no to theader-tdname.

concatenate wa_vbeln item_num1 into theader-tdname.

Thanks,

Anurag,

Read only

0 Likes
5,453

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.

Read only

0 Likes
5,453

Hi Anurag,

Why are we not using the text parameter order_text present in BAPI BAPI_SALESORDER_CREATEFROMDAT2 instead of SAVE_TEXT? you are bringing in unnecessary code and complexity by using separate code for saving the text which could be done usinG BAPI.; I would say this is not a right approach unless we got a right reason for that. also, you need not worry about passing the value to SAVE_TEXT for using BAPI to do this. Please post the code used to pass the text in BAPI which did not work for you in the initial case, let us see and find out and troubleshoot the issue.


Regards,

Read only

0 Likes
5,453

Dear Jagadeesh,

I also tried alot to upload long text using bapi... but failed

Plz find my code snippet....

but as suggested by nahbeet and kumar.. u can't update long text using bapi.

kindly suggest me the best way to update lont text..

*Item Long Text
          WA_TEXT-ITM_NUMBER  = ITEM_NUM.
          WA_TEXT-TEXT_ID     = 'Z001'.
          WA_TEXT-LANGU       = 'EN'.
          WA_TEXT-TEXT_LINE   = WA_SUB-LONG_TEXT.  " type 132 charcters
          WA_TEXT-LANGU_ISO   = 'EN'.
          WA_TEXT-FUNCTION    = '009'.
*          wa_text-format_col  = '*'.
          APPEND WA_TEXT TO IT_TEXT.
          CLEAR WA_TEXT..

Read only

0 Likes
5,453

Dear Kumar,

I have passed the item data (it_sub) which has long text and here item num is created internally.

so thats why i am passing the value by declaring variable(item_num/ item_num1).

and here TDID is Z001(fuctional people created this for special purpose).

even though i tried to update using tdid - 0001 .. it is not updating with this value.

if it is needed i will post the total code.

Read only

0 Likes
5,453

Hi Anurag,

Can you remove function parameter from passing to the BAPI parameter? keep it blank and test.And langu should be E. try the below code for BAPI

*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.  " type 132 charcters

            wa_text-format_col  = '*'.

          APPEND WA_TEXT TO IT_TEXT.

          CLEAR WA_TEXT.

Read only

0 Likes
5,453

Dear Prasanna,

I tried with your code.. still it is not updating.

i tried with all the scenarios.. but not succeed.

plz help me.

Read only

0 Likes
5,453

can you create a salesorder with this text manually in the system? I think there is a config issue, try to do it manually and find out you can successfully do that. Wrong config could potentially cause such issue, example TEXT ID not assigned to a language could be one of the reason.. Hope this helps.. keep me posted. 

Read only

0 Likes
5,453

Hi Anurag,

You are right in passing the Item Text Code as defined by the FC in the config - 'Z001'.

Also, better to pass item text directly to the BAPI, but still just try this.

Manually call the FM 'SAVE_TEXT' from SE37 in sequence with 'BAPI_TRANSACTION_COMMIT'.

Pass:

1. Header-tdobject = 'VBBP'

2. Header-tdname = (Concatenate 10 digit Sales Order Number with 6 digit item number) Please ensure this is a 16 digit number with pre-fixed zeroes if needed - 0010001234000010

3. Header-tdid = 'Z001'

4. Header-tdspras = sy-langu

5. lines-tdline = 'Hi'.

If this works, you'll get your solution.

I've referred this link of Thomas: http://scn.sap.com/thread/1061094

Regards,

Pranav.

Read only

0 Likes
5,453

Also a quick check for any exceptions raised by the FM 'SAVE_TEXT' or by the BAPI for the Salesorder Item Text or Header Text as applicable.

Regards,

Pranav.

Read only

0 Likes
5,453

Try doing the below things for sales order item things and let me know what are you getting in the desired text header. Are you passing the same information in SAVE_TEXT ?please check in debug mode and post

Read only

0 Likes
5,453

Dear Kumar,

i check in debug mode the data which i have passed to theader to save_text

is as same as what i see i see in the  vf02/3 item -> header level.

I find one difference -in my so item level two text ids 0001, z001.

after saving data manually for z001 -> short title 1 = VA02SAPMV45A

                                           0001-> short title 1 = ZREIZPS_REIM ( it is automatically updated)

Read only

0 Likes
5,453

Dear jagadessh,

manually it is getting saved.

but using bapi only it is not getting updated.

and can u tell me how do i assign language to text id.....!

Read only

0 Likes
5,453

Dear Pranav,

i checked return messages also.. for save_text - sy-subrc = 0.

and in bapi it_return no error message.

Read only

0 Likes
5,453

The last post is not very clear.

Anyways.. chose

  savemode_direct = 'X' in the FM.

Short title is not mandatory though you may pass any descriptive message.

Btw you are refering to va01/02 rite and not vf01/02 as mentioned in the last post? and what is the relation between 0001 and z0001? You want to update both?

Read only

0 Likes
5,453

Hi Anurag,

Sorry to repeat some points, but this thread has stretched a bit too long and is confusing .

1. You have tried using SAVE_TEXT manually and it was successful. So, ideally these values will help you to get the desired result.

2. You attempted using SAVE_TEXT in your program by calling it after the BAPI, but failed. Here, the BAPI's output Sales Order No. must have been used with the Item Number concatenated to form a number of 16 digits. Please check in debug-mode for the values passed and errors from the FM SAVE_TEXT again. Header-tdobject, Header-tdname, Header-tdid, Header-tdspras & lines-tdline

3. Finally and Ideally the internal table ORDER_TEXT should be used with the BAPI to add Item Text. Here, you need to pass ORDER_ITEMS_INX-UPDATEFLAG = 'I'

ORDER_TEXT-ITM_NUMBER = 6 digit, (please verify again in debug mode)

ORDER_TEXT-TEXT_ID, ORDER_TEXT-LANGU, ORDER_TEXT-TEXT_LINE.

I have successfully tested this and it works fine with minimal data.

Regards,

Pranav

Read only

0 Likes
5,453

Problem get resolved using bapi only(Not using save_text).

Actually here item num is internal assignment ...

now i pass that number for all  the using structures.

now long text is getting updated Succesfully.

Thnak you so much for Pranav Mandelia, Prasanna Jagadeesh, Kumar Gaurav.

Read only

former_member189779
Active Contributor
0 Likes
5,453

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.

Read only

0 Likes
5,453

I think save_text itself commit the text.

even thought i tried commit_text.. it's also don't make any diffrence.. text not updated.

Read only

madhu_vadlamani
Active Contributor
0 Likes
5,453

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.