Application Development 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: 

Using Function module BAPI_PR_CREATE Header Text not able to add

former_member196331
Active Contributor
0 Kudos

hi,

I am facing one problem I am using
CALL FUNCTION 'BAPI_PR_CREATE' For creating Purchase Request,
Everything is correct, But Purchase Header text i am not able to Add it, I have 3 Header texts At Indent ME51n. It only taking only one text for each indent.
If i give at a time 3 texts only last one which means what i passed last in the code it is taking as header text

like in coding.

header text1

header text2

header text3.

It only update Header text3.

IT_HTEXT TYPE BAPIMEREQHEADTEXT OCCURS 0,

The code is like.

IF WA_FINAL1-HTEXT1 IS NOT INITIAL.
WA_HTEXT-TEXT_ID = 'B01'.
WA_HTEXT-TEXT_LINE = WA_FINAL1-HTEXT1.
APPEND WA_HTEXT TO IT_HTEXT.
CLEAR : WA_HTEXT.
ENDIF.

IF WA_FINAL1-HTEXT1 IS NOT INITIAL.
WA_HTEXT-TEXT_ID = 'B02'.
WA_HTEXT-TEXT_LINE = WA_FINAL1-HTEXT1.
APPEND WA_HTEXT TO IT_HTEXT.
CLEAR : WA_HTEXT.
ENDIF.

IF WA_FINAL1-HTEXT1 IS NOT INITIAL.
WA_HTEXT-TEXT_ID = 'B03'.
WA_HTEXT-TEXT_LINE = WA_FINAL1-HTEXT1.
APPEND WA_HTEXT TO IT_HTEXT.
CLEAR : WA_HTEXT.
ENDIF.

All header texts not able to pass.Any suggestions update me, If it is not possible Please provide me Alternatives.

11 REPLIES 11

NTeunckens
Active Contributor

Please check SAP-KBA 2075535 "BAPI_PR_CREATE: one header text" for this.

Extract :

"Cause
Even if you are able to define more than one text ID for the Preq, the system can only handle one text on the header level, text id B01, because they are considered internal documents, which does not support the creation of additional header memos.
In the standard SAP system, entering other header texts alongside the header memos is not supported.

Resolution
It is also not possible for online transaction codes. When using transaction ME51N, if you try to insert a test for the second text id, system will clear it out. Only the Header Note B01 will be considered. When using the BAPI, system will concatenate the two text IDs in the B01.
This functionality was not programmed in the system."

0 Kudos

hi, thanks for you reply.
Solution i did not understood.What i understood is, I has to enter either 1 or 2 or 3.
Only one should be inserted.

I tried, any one it is taking. But not multiple.

0 Kudos

This means that the BAPI can not do more than what you can do via SAP Enjoy transaction.

Please try to add Multiple HeaderTexts in your PR via trx. "ME51N" ... Then the following behaviour should occur, mentioned in the KBA :

"It is also not possible for online transaction codes. When using transaction ME51N, if you try to insert a test for the second text id, system will clear it out. Only the Header Note B01 will be considered"

0 Kudos

Did some tests myself and indeed :

  • You can Update the Texts only for one 'TEXT_ID' at a Time ... In my Test THE LAST TEXT_ID is used to Fill the HeaderTexts ...
  • By filling the 'TEXT_FORM' in the HEADERTEXT-structure with ' / ' you can set up the Texts as Separate lines ...

 IF WA_FINAL1-HTEXT1 IS NOT INITIAL.
   WA_HTEXT-TEXT_ID   = 'B01'.    "Won't be used, only the ID of LAST RECORD of HDRTXT-Table!
   WA_HTEXT-TEXT_FORM = '/'.      "SET AS A NEW LINE
   WA_HTEXT-TEXT_LINE = WA_FINAL1-HTEXT1.
   APPEND WA_HTEXT TO IT_HTEXT.
   CLEAR : WA_HTEXT.
 ENDIF.

 IF WA_FINAL1-HTEXT1 IS NOT INITIAL.
   WA_HTEXT-TEXT_ID = 'B02'.      "LAST RECORD HDRTXT-Table => ALL RECORDS added with this ID
   WA_HTEXT-TEXT_FORM = '/'.      "SET AS A NEW LINE
   WA_HTEXT-TEXT_LINE = WA_FINAL1-HTEXT1.
 APPEND WA_HTEXT TO IT_HTEXT.
 CLEAR : WA_HTEXT.
 ENDIF.


That is how it worked in my system ...?

0 Kudos

I passed the data like above,

Still same problem only B02 is adding i mean last one it is updating the text.

Can i use any Save_text function module

former_member200754
Participant
0 Kudos

Hi Kali,

try to set break point at FM : SAVE_TEXT and check some parameter input to FM, maybe you input wrong some data.

Thanks,

John

0 Kudos

No no lot of posts are available, Like above problem, But no solution for above one.
Default behavior is like this, as per my knowledge.

0 Kudos

Did you debug as i suggest ? and no error return after call FM save_text ?

Also call bapi commit if you are missing

0 Kudos

I am calling commit.

VenkatRamesh_V
Active Contributor
0 Kudos

Hi kali,

Try passing the text with the pr item in the structure PRITEMTEXT TYPE BAPIMEREQITEMTEXT.

Hope it helpful,

Regards,

Venkat.

0 Kudos

I need at header not item level, Item level working fine. Ok correct me anything is wrong.