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: 

Capture data after 'call transaction using bdcdata'

Former Member
0 Kudos

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.

----


1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

10 REPLIES 10

former_member186741
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

Hallo,

tried what suggested by sudhir, but it does not work.

No position number in the messages tab.

Any other idea?

regards,

marco

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Ok, I found it. It is parameter id PON.

GET PARAMETER ID <b>'PON'</b> FIELD posid. 

Regards,

Rich Heilman

0 Kudos

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

0 Kudos

I actually did some debugging of the PBO module, to see the GET statement.

Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos

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