2014 Sep 02 5:36 PM
Hello Gurus,
I am creating a PR using BAPI_PR_CREATE, I achieve creating the PR, but I can't save value in the custom fields.
This is my code, would you please help me?
Thanks
DATA: ls_req_item TYPE BAPI_TE_MEREQITEM,
ls_req_itemx TYPE BAPI_TE_MEREQITEMX,
ls_extensionin TYPE bapiparex,
lt_extensionin TYPE STANDARD TABLE OF bapiparex.
clear ls_extensionin.
clear ls_req_item.
ls_req_item-preq_item = wa_gt_data-posic.
ls_req_item-ZZKOSTL = wa_praccount-costcenter.
ls_extensionin-structure = 'BAPI_TE_MEREQITEM'.
PERFORM transfer_to_extensionin USING ls_req_item CHANGING ls_extensionin.
APPEND ls_extensionin to lt_extensionin.
clear ls_extensionin.
clear ls_req_itemx.
ls_req_itemx-preq_item = wa_gt_data-posic.
ls_req_itemx-ZZKOSTL = 'X'.
ls_extensionin-structure = 'BAPI_TE_MEREQITEMX'.
PERFORM transfer_to_extensionin USING ls_req_itemx CHANGING ls_extensionin.
APPEND ls_extensionin to lt_extensionin.
FORM transfer_to_extensionin
USING
is_bapi_extensionin TYPE any
CHANGING
cs_bapiparex TYPE bapiparex.
DATA l_distance_characters TYPE I.
FIELD-SYMBOLS <any> TYPE any.
DESCRIBE DISTANCE BETWEEN cs_bapiparex-structure
AND cs_bapiparex-valuepart1
INTO l_distance_characters
IN CHARACTER MODE.
ASSIGN cs_bapiparex+l_distance_characters(*) TO <any>
CASTING LIKE is_bapi_extensionin.
<any> = is_bapi_extensionin.
ENDFORM.
* Create the PR with the above data's.
CALL FUNCTION 'BAPI_PR_CREATE'
EXPORTING
prheader = wa_header
prheaderx = wa_headerx
TABLES
return = t_return
pritem = t_item
pritemx = t_itemx
praccount = t_praccount
praccountx = t_praccountx
"pritemsource = t_itemsource
"pritemtext = t_itext
EXTENSIONIN = lt_extensionin
EXCEPTIONS
OTHERS = 1.
2014 Sep 04 4:02 PM
Hi everyone,
Thank you all for your time and suggestions, I have the answer, because all custom fields of append structure are not CHAR, I can't update customs fields using EXTENSIONIN of BAPI_PR_CREATE.
I think my only solution is to use a simple UPDATE EBAN SET.... WHERE banfn = ....
Thank you all for your valuable time.
2014 Sep 02 8:25 PM
- Did you add the custom fields in BAPI_TE_MEREQITEM and BAPI_TE_MEREQITEMX under the append structure CI_EBANDB / CI_EBANDBX or create a new one? Make sure you have used CI_*** append structures;
- Implement the BADI ME_BAPI_PR_CUST put a break in the method MAP2I_EXTENSIONIN and check if IM_CONTAINER is filled.
Regards,
Felipe
2014 Sep 02 8:31 PM
Hi Felipe,
Yes, I have done that.
The transparent table EBAN has an .INCLUDE begins with CI_***, here are all the custom fields of a PR.
I will take a look at BADI ME_BAPI_PR_CUST, I will debug it.
I'll let you know.
thanks
2014 Sep 03 6:09 AM
Hi Enrique,
please try as a first step to replace
PERFORM transfer_to_extensionin USING ls_req_item CHANGING ls_extensionin.
with
MOVE ls_req_item TO ls_extensionin+30.
and to replace
PERFORM transfer_to_extensionin USING ls_req_itemx CHANGING ls_extensionin.
with
MOVE ls_req_itemx TO ls_extensionin+30.
If this will work, you can improve this code for the code inspector.
Regards,
Klaus
2014 Sep 03 3:18 PM
Hi Klaus,
It doesn't work, when I write the sentence MOVE...... I have an error , IT SAYS
"LS_EXTENSIONIN+30(960)" and "LS_REQ_ITEM" are not mutually convertible in a Unicode program. .
Thanks
2014 Sep 03 10:01 PM
Hi,
BAPI_TE_MEREQITEM (include CI_EBANDB) should have only char and similar datatypes.
Please read carefully documentation of function BAPI_PR_CREATE parameter EXTENSIONIN and note 509898. Maybe You've to implement BADI described by Felipe.
Regards,
Jarek
2014 Sep 03 10:42 PM
Hi Jaroslaw,
Thank for answering, I am Reading the note, OK I understand, but still I am figuring out how to solve my problema, I am new at BADI, I am Reading now how to do it.
If you have some lines of code ABAP that can help me please, I will appreciate it. Or Perhaps a Link to read in more detail about this.
Sorry.
Thanks
2014 Sep 04 5:48 AM
Hi Enrique,
then try the following: Replace
PERFORM transfer_to_extensionin USING ls_req_item CHANGING ls_extensionin.
with
DESCRIBE FIELD ls_req_item LENGTH h_length IN BYTE MODE.
MOVE ls_req_item TO ls_extensionin+30(h_length).
and replace
PERFORM transfer_to_extensionin USING ls_req_itemx CHANGING ls_extensionin.
with
DESCRIBE FIELD ls_req_itemx LENGTH h_length IN BYTE MODE.
MOVE ls_req_itemx TO ls_extensionin+30(h_length).
where h_length is defined as
DATA: h_length TYPE i.
I've checked this in a small sample report and it worked for me
REPORT ztest_extensionin.
DATA: ls_req_item TYPE bapi_te_mereqitem.
DATA: ls_req_itemx TYPE bapi_te_mereqitemx.
DATA: ls_extensionin TYPE bapiparex.
DATA: h_length TYPE i.
START-OF-SELECTION.
DESCRIBE FIELD ls_req_item LENGTH h_length IN BYTE MODE.
MOVE ls_req_item TO ls_extensionin+30(h_length).
DESCRIBE FIELD ls_req_itemx LENGTH h_length IN BYTE MODE.
MOVE ls_req_itemx TO ls_extensionin+30(h_length).
Regards,
Klaus
2014 Sep 04 1:06 PM
Please try use Klaus code, could help (I didn't try). You can also search SDN with keys: BAPI_PR_CREATE, EXTENSIONIN.
In documentation of EXTENSONIN parametr there is link to SAP help, it' realy useful.
Jarek
2014 Sep 04 2:51 PM
Hi Klaus,
There must be something different in my report about yours, because I have this error.
I have debug and the line where the report fails is the following:
MOVE ls_req_item TO ls_extensionin+30(h_length).
I have the same declarations lines :
DATA: ls_req_item TYPE BAPI_TE_MEREQITEM,
ls_req_itemx TYPE BAPI_TE_MEREQITEMX,
ls_extensionin TYPE bapiparex,
lt_extensionin TYPE STANDARD TABLE OF bapiparex.
2014 Sep 04 3:04 PM
The error says that the structure ls_req_item is longer then extensionin.
ls_req_item = 1260 long and extensionin is only 990 long. That is why it dumps.
It is up to you now to check why ls_req_item is that long.
2014 Sep 04 3:11 PM
Hi,
Thank your for your answer, Yes I understand the error, I know, but I don't how to solve it. this the structure of ls_req_ítem, there are almost 60 fields, the image is only a portion.
Thanks again
2014 Sep 04 3:22 PM
Can you split up the fields and values ? Extensionin is a table.
2014 Sep 04 3:28 PM
The BAPI extension can have the maximum length of 960 characteres, you can find SAP documentation below:
Appending Customer Fields - Enhancements, Modifications, ? (CA-BFA) - SAP Library
Seems that your append structure has more than permitted, you can try this way below to try to update the fields up to 960 characteres, sincerly i didn't try and I don't know if it will work, but the fields from character 960 onwards surely cannot be updated by BAPI extension.
MOVE ls_req_item(960) TO ls_extensionin+30(960).
Regards,
Felipe
2014 Sep 04 3:41 PM
2014 Sep 04 3:52 PM
If I were you I would go through the link provided by Felippe and see if you followed all the guidelines EXACTLY. Especially concerning the Include and append to be used and the fields in this append structure.
One thing I saw when I read the documentation in the link is:
"Customers can use only fields of data type CHAR and similar data types in BAPI table extensions"
2014 Sep 04 3:52 PM
You can only use characters fields for BAPI extension, in your append structure you have fields type QUAN, CURR, DEC, this is not supported for extension functionality.
Regards,
Felipe
2014 Sep 04 3:55 PM
Hi Felipe.
Ok, I got it, Ok that must the error, all the custom fields are not char, perhaps thats because I can't update custom fields using extensión.
2014 Sep 04 4:02 PM
Hi everyone,
Thank you all for your time and suggestions, I have the answer, because all custom fields of append structure are not CHAR, I can't update customs fields using EXTENSIONIN of BAPI_PR_CREATE.
I think my only solution is to use a simple UPDATE EBAN SET.... WHERE banfn = ....
Thank you all for your valuable time.
2014 Sep 04 11:10 PM
Hello Enrique,
here is a solution to fill the valuepart1 of the extension structure: you can CAST both source and destination to field symbols of type X to copy a structure with non-character fields (struc) to a character container (dest) in an unicode system. Instead of writing
DEST = STRUCuse:
field-symbols: <struc> TYPE X, <dest> TYPE X.
assign: struc TO <struc>, dest TO <dest>.
<dest> = <struc>.
Also check class CL_ABAP_CONTAINER_UTILITIES.
regards,
JNN
2014 Sep 04 11:33 PM
Hi Jacques,
Thank you for your time,
This is my code ABAP now, but it sill doen't work, perhaps it is like Felipe says, only char must declare in APPEND STRUCTURE, but I have different types.
CLEAR ls_extensionin.
CLEAR ls_req_item.
MOVE: wa_gt_data-posic TO ls_req_item-preq_item.
MOVE: wa_praccount-costcenter TO ls_req_item-ZZKOSTL.
CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = ls_req_item
IMPORTING
ex_container = ls_extensionin+30
EXCEPTIONS
OTHERS = 0.
MOVE 'BAPI_TE_MEREQITEM' TO ls_extensionin-structure.
APPEND ls_extensionin to lt_extensionin.
CLEAR ls_extensionin.
CLEAR ls_req_itemx.
MOVE: wa_gt_data-posic TO ls_req_itemx-preq_item.
MOVE: 'X' TO ls_req_itemx-ZZKOSTL.
CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = ls_req_itemx
IMPORTING
ex_container = ls_extensionin+30
EXCEPTIONS
OTHERS = 0.
MOVE 'BAPI_TE_MEREQITEMX' TO ls_extensionin-structure.
APPEND ls_extensionin to lt_extensionin.
Thanks
2014 Sep 05 1:27 AM
Hello Enrique,
your logic seems correct.
But now you must implement BAdI ME_BAPI_PR_CUST because you have non CLIKE fields in the CI_EBANDB structure. Use the read_container_c( ) in method map2i_extensionin( ). Make sure OSS Note 1111291 is applied to your system.
best regards,
JNN
2014 Sep 05 6:59 AM
Hi Enrique,
if you want to update EBAN with
UPDATE EBAN SET
please do this in an update function module with CALL FUNCTION ... IN UPDATE TASK.
First lock the PR (same locks as in ME52N), then get all update values and pass them to the function module in update task, and then finally do a COMMIT to call the function module and release the PR.
Another idea is to shrink BAPI_TE_MEREQITEM to the fiedls you really want to update by BAPI. I don't think you need all custom fields for update here.
Regards,
Klaus
2014 Sep 05 2:32 PM
Hi Jacques,
I am reading the note but I don't understand the solution., sorry.
I tried to implement the BADI but I have the following message.
2014 Sep 05 2:35 PM
2014 Sep 05 3:44 PM
Hi Enrique,
The badi name is ME_BAPI_PR_CUST and not BADI ME_BAPI_PR_CUST. Leave out the BADI part
2014 Sep 05 3:51 PM
2014 Sep 05 4:02 PM
Go to transaction SE18 and try again.
Check the enhancement spot ES_BADI_ME_BAPI.
BAdI Definition ME_BAPI_PR_CUST is part of this spot.
JNN
2014 Sep 05 4:08 PM
You are in the BADI implementation tcode (SE19), you have to go in BADI definition SE18 and then look for ME_BAPI_PR_CUST.
Regards,
Felipe
2014 Sep 05 4:35 PM
Hi Felipe,
I've read in your first ANSWER that I have to implement the BADI ME_BAPI_PR_CUST.Do I have to go to trx SE18 To implement?
Sorry I am new at implementing BADIs
Best Regards.
2014 Sep 05 4:48 PM
- Go to SE18 and fill BADI Name with ME_BAPI_PR_CUST then Display;
- On the left side you will find a panel with BAdI definitions click with the right button on ME_BAPI_PR_CUST and then Create BAdI Implementation;
- On new the popscreen, create a new Enhancement implementation.
Regards,
Felipe
2014 Sep 05 4:52 PM
Enrique, I highly recommend you to read the SAP documentation to get some knowledge about what you're doing.
Business Add-Ins (BAdIs) - Enhancement Framework - SAP Library
Regards,
Felipe
2014 Sep 05 5:06 PM
Hi Felipe,
I am reading the link now, thanks for the help.
Best Regards.
2014 Sep 10 4:52 PM
Hi Filipe,
Do you have an example of how to implement it?
Thanks
2014 Sep 10 5:38 PM
If you don't need to do any validation just put the code below:
ch_struc = im_container.
if you need to do any validation you can follow the example that SAP suggests (your print), in your tests put a break point in the badi and check if im_container is filled with all the values.
Regards,
Felipe
2014 Sep 10 8:04 PM
The parameter IM_CONTAINER has the following type.
Is there a quick way to convert this long char VALUEPART1 to the structure
CH_STRUC
2014 Sep 10 8:46 PM
Hello Enrique,
my proposal: delete lines 13 to 21 from your screenshot and insert your code there.
CASE im_name.
WHEN 'CI_EBANDB' OR 'CI_EBANDBX'.
* ToDo: convert im_container to ch_struc.
* use class CL_ABAP_CONTAINER_UTILITIES
* method read_container_c( ).
lf_done = 'X'.
ENDCASE.
happy coding..
JNN
2014 Sep 10 9:18 PM
Hi Jacques,
Thank you, I will try to convert using CL_ABAP_CONTAINER_UTILITIES.
Best Regards.
2014 Sep 10 11:35 PM
2025 Jul 16 12:43 PM
Hi,
I just want to take a moment and request regarding the updating of custom fields, which I am performing, but it is not updating. Could you please share with me the insights related to that, like what shoud I actually need to write in the Mape21 extension method?