08-01-2006 12:13 AM
Hallo,
I am working with an object Delegation to PDOTYPE_SH, and i have build the dialogue method ZCREATEDIALOGPP03, which call PP03 creates a new HR position. Some of the data (as you can see in my semplified method below) necessary to create the position are passed using the call transaction for PP03 using bdc.
At the end, I would like to get the new Position ID created, to use it and pass it on for further processing.
How can I capture that in my method?
Please have a look below at my code.
Regards,
Marco
-
BEGIN_METHOD ZCREATEDIALOGPP03 CHANGING CONTAINER.
DATA:
objtype type PPHDR-OTYPE,
BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
prepare parameter ID
objtype = 'S'.
set paramater ID PP03
SET PARAMETER ID 'POT' FIELD objtype.
open bdc call
clear bdcdata.
refresh bdcdata.
bdc for Position Text
perform bdc_dynpro tables bdcdata using 'MP100000' '2000'.
perform bdc_field tables bdcdata using 'P1000-STEXT' PLSTX.
call transaction PP03
Call transaction 'PP03' using bdcdata.
end_method.
----
Start new screen *
----
FORM BDC_DYNPRO tables ibdcdata USING PROGRAM DYNPRO.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA to ibdcdata.
ENDFORM.
----
Insert field *
----
FORM BDC_FIELD tables ibdcdata USING FNAM FVAL.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: NODATA_CHARACTER VALUE '/'.
IF fval <> NODATA_CHARACTER.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA to ibdcdata.
ENDIF.
ENDFORM.
----
08-01-2006 12:26 AM
Put this in your code :
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: opttable LIKE ctu_params.
INITIALIZATION.
opttable-dismode = 'N'.
opttable-updmode = 'L'.
opttable-racommit = 'X'.
Change the call transaction statement as follow.
Call transaction 'PP03' using bdcdata OPTIONS FROM opttable MESSAGES INTO messtab.
Now loop on messtab and you will find the persons id in messtab-msgv1.
Let me know if you have questions.
Award points if usefull.
08-01-2006 12:23 AM
maybe the new number is returned in a sap message try something like this:
data t_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
REFRESH t_messtab.
CALL TRANSACTION tcode USING t_bdcdata
MESSAGES INTO t_messtab.
LOOP AT t_messtab.
PERFORM expand_error_message USING t_messtab
w_error_message.
endloop.
FORM expand_error_message USING f_raw_message STRUCTURE bdcmsgcoll
f_editted_message.
DATA v_work_text LIKE bdcmsgcoll-msgv1.
DATA v_length TYPE i.
FIELD-SYMBOLS <newtext>.
SELECT SINGLE * FROM t100
WHERE sprsl = sy-langu
AND arbgb = f_raw_message-msgid
AND msgnr = f_raw_message-msgnr.
CLEAR f_editted_message.
MOVE t100-text TO f_editted_message.
DO 4 TIMES
VARYING v_work_text FROM f_raw_message-msgv1
NEXT f_raw_message-msgv2.
v_length = STRLEN( v_work_text ).
IF v_length = 0.
ASSIGN ' ' TO <newtext>.
ELSE.
ASSIGN v_work_text(v_length) TO <newtext>.
ENDIF.
REPLACE '&' WITH <newtext> INTO f_editted_message.
CONDENSE f_editted_message.
ENDDO.
ENDFORM. "EXPAND_ERROR_MESSAGE
08-01-2006 12:26 AM
Put this in your code :
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: opttable LIKE ctu_params.
INITIALIZATION.
opttable-dismode = 'N'.
opttable-updmode = 'L'.
opttable-racommit = 'X'.
Change the call transaction statement as follow.
Call transaction 'PP03' using bdcdata OPTIONS FROM opttable MESSAGES INTO messtab.
Now loop on messtab and you will find the persons id in messtab-msgv1.
Let me know if you have questions.
Award points if usefull.
08-02-2006 3:24 PM
Hallo,
tried what suggested by sudhir, but it does not work.
No position number in the messages tab.
Any other idea?
regards,
marco
08-02-2006 3:28 PM
When you do the transaction manually, do you get a success message telling you the position number? If so, then this message should definitly be getting sent back thru the MESSAGES into Messtab extension when you do a BDC. If you don't get any such message, then can not get the new number from the BDC. You would have to do something else.
Do the transaction manually first and make sure that a "S" message with the number is triggered at the end of the transaction.
Regards,
Rich Heilman
08-02-2006 3:49 PM
Actually the position number is not output by a message.
After the PP03 is completed and all the position infotype are created,
the system gets back to the starting screen in PP03 and fill the relevant field 'position id' with the position number just created. Meaning:
- At the beginning, when calling the PP03 the position field 'position id' is empty.
- then infotypes are created.
- Then get back to initial screen and the just created position number is in field 'position id'.
Any ideas?
Thank you and regards,
Marco
08-02-2006 3:55 PM
Ahhh......yes!!! I think we may be able to pull it out of memory id. Go to the screen where it filled in the position id. Do F1 on this field, click the technical settings button. See what the parameter id is for this field. Now go to your code, after the call transation statement, get the value in the parameter id.
In the following statement, PID represents the parameter id that you dicovered earlier.
data: posid(20) type c.
get parameter id 'PID' field posid.
Regard,
Rich Heilman
08-02-2006 4:04 PM
08-02-2006 4:33 PM
Great!
Problem solved.
Thank you very much.
Question: how did you get the parameter id 'PON'?
it is not that straightforward..
thank you again!
marco
08-02-2006 4:40 PM
08-02-2006 3:30 PM
<b>data: it_mesg like bdcmsgcoll occurs 0 with header line.
data: v_message(100).
</b>
clear bdcdata.
refresh bdcdata.
bdc for Position Text
perform bdc_dynpro tables bdcdata using 'MP100000' '2000'.
perform bdc_field tables bdcdata using 'P1000-STEXT' PLSTX.
call transaction PP03
<b>Call transaction 'PP03' using bdcdata update 'S'
mode 'N
messages into it_mesg.
loop at it_mesg.
call function 'FORMAT_MESSAGE'
exporting
id = it_mesg-msgid
lang = sy-langu
no = it_mesg-msgnr
v1 = it_mesg-msgv1
v2 = it_mesg-msgv2
v3 = it_mesg-msgv3
v4 = it_mesg-msgv4
importing
msg = v_message
exceptions
not_found = 1
others = 2.
write:/ v_message.
endloop.</b>