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

How to use variable with refrence to program into BADI

Former Member
0 Likes
811

Hi Experts,

I am working on one BADI (MB_MIGO_BADI) with MIGO, I am not able to excess PO number that is entered on the main screen.

I need this value in my defined field of BADI.

while debugging I can see the PO value into variable

(SAPLMIGO) GODYNPRO-PO_NUMBER, but if I give only GODYNPRO-PO_NUMBER then I am not able to get value into debugger.

So my question is how to define a variable that will be same as (SAPLMIGO) GODYNPRO-PO_NUMBER type.

I tried somthing like this:

data: LV_PO type EBELN

LV_PO = (SAPLMIGO) GODYNPRO-PO_NUMBER but this gives syntax error.

Points will be rewarded for helpful answer.

neo

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
565

Hi

You need to declare a Field symbol of type any and assaign PO number value to the Field symbol.

eg:

FIELD-SYMBOLS <fs_xjkap> TYPE any.

l_name = '(SAPMJ45A)XJKAP'.

ASSIGN (l_name) TO <fs_xjkap>.

IF <fs_xjkap> IS ASSIGNED.

MOVE <fs_xjkap>-vbeln TO l_vbeln.

MOVE <fs_xjkap>-posnr TO l_posnr.

ENDIF.

regards,

raghu

Hi

You need to declare a Field symbol of type any and assaign PO number value to the Field symbol.

eg:

FIELD-SYMBOLS <fs_xjkap> TYPE any.

l_name = '(SAPMJ45A)XJKAP'.

ASSIGN (l_name) TO <fs_xjkap>.

IF <fs_xjkap> IS ASSIGNED.

MOVE <fs_xjkap>-vbeln TO l_vbeln.

MOVE <fs_xjkap>-posnr TO l_posnr.

ENDIF.

regards,

raghu

2 REPLIES 2
Read only

Former Member
0 Likes
565

Try using the function module

'DYNP_VALUES_READ'. by passing the program name, screen number for the PO number in badi

Example code

REPORT Z_SRI_HELP_VALUE_FOR_TABLES .

tables tcurt.

DATA DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.

PARAMETERS: P_WAERS LIKE TCURT-WAERS, "Currency

P_LTEXT LIKE TCURT-LTEXT, "Long Text

P_KTEXT LIKE TCURT-KTEXT. "Short Text

*----


*--- Example of updating value of another field on the screen -


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.

CLEAR: DYFIELDS[], DYFIELDS.

*--- select currency

CALL FUNCTION 'HELP_VALUES_GET'

EXPORTING

fieldname = 'WAERS'

tabname = 'TCURT'

IMPORTING

SELECT_VALUE = P_WAERS.

*--- get long text for the selected currency

SELECT SINGLE LTEXT FROM TCURT

INTO DYFIELDS-FIELDVALUE

WHERE SPRAS = SY-LANGU

AND WAERS = P_WAERS.

IF SY-SUBRC <> 0.

CLEAR DYFIELDS-FIELDVALUE.

ENDIF.

*--- update another field

DYFIELDS-FIELDNAME = 'P_LTEXT'.

APPEND DYFIELDS.

CALL FUNCTION 'DYNP_VALUES_UPDATE'

EXPORTING

DYNAME = SY-CPROG

DYNUMB = SY-DYNNR

tables

dynpfields = DYFIELDS .

*----


*--- Example of reading value of another field -


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KTEXT.

*--- read another field

CLEAR: DYFIELDS[], DYFIELDS.

DYFIELDS-FIELDNAME = 'P_WAERS'.

APPEND DYFIELDS.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = SY-CPROG

DYNUMB = SY-DYNNR

TABLES

DYNPFIELDS = DYFIELDS .

READ TABLE DYFIELDS INDEX 1.

*--- get short text and update current field

SELECT SINGLE KTEXT FROM TCURT

INTO P_KTEXT

WHERE SPRAS EQ SY-LANGU

AND WAERS EQ DYFIELDS-FIELDVALUE.

Thanks

Mahesh

Read only

Former Member
0 Likes
566

Hi

You need to declare a Field symbol of type any and assaign PO number value to the Field symbol.

eg:

FIELD-SYMBOLS <fs_xjkap> TYPE any.

l_name = '(SAPMJ45A)XJKAP'.

ASSIGN (l_name) TO <fs_xjkap>.

IF <fs_xjkap> IS ASSIGNED.

MOVE <fs_xjkap>-vbeln TO l_vbeln.

MOVE <fs_xjkap>-posnr TO l_posnr.

ENDIF.

regards,

raghu