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 write BDC in Function exit (user exit )

Former Member
0 Likes
661

Hi champs,

I am trying to write one bdc code in a function exit but it is giving me the error:

" Incorrect nesting: Before the statement "FORM", the structure

introduced by "FUNCTION" must be concluded with "ENDFUNCTION". -

The code which i have written is

*&----


**& Include ZXMRCU01

*&----


*

data: begin of it_imptt occurs 0,

POINT like imptt-point,

MRMIN like imptt-MRMIN,

MRMAX like imptt-MRMAX,

end of it_imptt.

*****************************************

  • Internal table to store BDC screens *

  • and field values *

*****************************************

DATA: BEGIN OF it_BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF it_BDCDATA.

select point

MRMIN

MRMAX from imptt into it_imptt

for all entries in imrg_ins

where point = imrg_ins-point.

endselect.

read table imrg_ins with key point = it_imptt-point.

if imrg_ins-readg < it_imptt-mrmin

or imrg_ins-readg > it_imptt-mrmax.

perform bdc_dynpro using 'SAPLIQS0' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RIWO00-QMART'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RIWO00-QMART'

'M1'.

perform bdc_dynpro using 'SAPLIQS0' '7200'.

perform bdc_field using 'BDC_OKCODE'

'=BUCH'.

perform bdc_field using 'VIQMEL-QMTXT'

'test desc1'.

call transaction 'IW21'

using it_BDCDATA

Mode 'A'

update 'S'.

REFRESH it_BDCDATA.

endif.

*&----


**& Form bdc_dynpro

*&----


    • text ---- Taking 2 parameters Screen Name & Screen Number.

*----


FORM BDC_DYNPRO USING SCREEN_NAME SCREEN_NUMBER.

CLEAR it_BDCDATA.

it_BDCDATA-PROGRAM = SCREEN_NAME.

it_BDCDATA-DYNPRO = SCREEN_NUMBER.

it_BDCDATA-DYNBEGIN = 'X'.

APPEND it_BDCDATA.

ENDFORM. "bdc_dynpro

*

*&----


**& Form bdc_field

*&----


    • text---- Taking 2 parameters Field Name & Field Number.

*----


FORM BDC_FIELD USING FNAME FVAL.

CLEAR it_BDCDATA.

it_BDCDATA-FNAM = FNAME.

it_BDCDATA-FVAL = FVAL.

APPEND it_BDCDATA.

ENDFORM. "bdc_field

Is there any different way of writing bdc in user exit?

2 REPLIES 2
Read only

Former Member
0 Likes
518

<b>FUNCTION.</b>

*&----


**& Include ZXMRCU01

*&----


*

data: begin of it_imptt occurs 0,

POINT like imptt-point,

MRMIN like imptt-MRMIN,

MRMAX like imptt-MRMAX,

end of it_imptt.

*****************************************

  • Internal table to store BDC screens *

  • and field values *

*****************************************

DATA: BEGIN OF it_BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF it_BDCDATA.

select point

MRMIN

MRMAX from imptt into it_imptt

for all entries in imrg_ins

where point = imrg_ins-point.

endselect.

read table imrg_ins with key point = it_imptt-point.

if imrg_ins-readg < it_imptt-mrmin

or imrg_ins-readg > it_imptt-mrmax.

perform bdc_dynpro using 'SAPLIQS0' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RIWO00-QMART'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RIWO00-QMART'

'M1'.

perform bdc_dynpro using 'SAPLIQS0' '7200'.

perform bdc_field using 'BDC_OKCODE'

'=BUCH'.

perform bdc_field using 'VIQMEL-QMTXT'

'test desc1'.

call transaction 'IW21'

using it_BDCDATA

Mode 'A'

update 'S'.

REFRESH it_BDCDATA.

endif.

<b>ENDFUNCTION.</b>

*&----


**& Form bdc_dynpro

*&----


    • text ---- Taking 2 parameters Screen Name & Screen Number.

*----


FORM BDC_DYNPRO USING SCREEN_NAME SCREEN_NUMBER.

CLEAR it_BDCDATA.

it_BDCDATA-PROGRAM = SCREEN_NAME.

it_BDCDATA-DYNPRO = SCREEN_NUMBER.

it_BDCDATA-DYNBEGIN = 'X'.

APPEND it_BDCDATA.

ENDFORM. "bdc_dynpro

*

*&----


**& Form bdc_field

*&----


    • text---- Taking 2 parameters Field Name & Field Number.

*----


FORM BDC_FIELD USING FNAME FVAL.

CLEAR it_BDCDATA.

it_BDCDATA-FNAM = FNAME.

it_BDCDATA-FVAL = FVAL.

APPEND it_BDCDATA.

ENDFORM. "bdc_field

Regards

Peram

Read only

0 Likes
518

Hi Prabhu,

I have used your code in one of my user exit it helped me lot to solve my problem do you have any idea how can i trigger a workflow now to dend the message user that the notification has been generated.

Thanks and Regards,

Rachit Khanna