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

Urgent: Regarding Runtime Error in FM

Former Member
0 Likes
1,453

hi,

i had made a Function Module which will reterive the production order,but when i use it in the program it gives runtime error.Plzz help me how to solve this problem.

1st i am pasting the code which i had written:-

FUNCTION ZFIND_PRDORD.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(QP_CHARG) LIKE CHVW-CHARG OPTIONAL

*" VALUE(P_AUFNR) LIKE CHVW-AUFNR OPTIONAL

*" EXPORTING

*" VALUE(P_RETVAL) LIKE CHVW-AUFNR

*"----


DATA : BEGIN OF T_CHVW OCCURS 0,

XZUGA LIKE CHVW-XZUGA,

WERKS LIKE CHVW-WERKS,

MATNR LIKE CHVW-MATNR,

CHARG LIKE CHVW-CHARG,

AUFNR LIKE CHVW-AUFNR,

EBELN LIKE CHVW-EBELN,

MBLNR LIKE CHVW-MBLNR,

ZEILE LIKE CHVW-ZEILE,

BUDAT LIKE CHVW-BUDAT,

SHKZG LIKE CHVW-SHKZG,

BWART LIKE CHVW-BWART,

MENGE LIKE CHVW-MENGE,

MEINS LIKE CHVW-MEINS,

KZBEW LIKE CHVW-KZBEW,

END OF T_CHVW.

SELECT XZUGA WERKS MATNR CHARG AUFNR EBELN

MBLNR ZEILE BUDAT SHKZG BWART MENGE MEINS KZBEW

FROM CHVW INTO TABLE T_CHVW

WHERE CHARG EQ QP_CHARG

and XZUGA = ' '

AND BWART = '101'

and aufnr eq p_aufnr

AND KZBEW = 'F' .

P_RETVAL = T_CHVW-AUFNR.

ENDFUNCTION.

Now i am displaying the program for testing this FM which gives the runtime error:-

TABLES : CHVW.

SELECT-OPTIONS : P_CHARG FOR CHVW-CHARG,

P_AUFNR FOR CHVW-AUFNR .

CALL FUNCTION 'ZFIND_PRDORD'

EXPORTING

QP_CHARG = P_CHARG

P_AUFNR = P_AUFNR

IMPORTING

P_RETVAL = P_AUFNR.

WRITE : / 'SDSQDA' .

Plzz help me out as how to solve this problem as i have to use it in

the main program.

regards,

ric.s

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,399

HI SANTOSH,

I had removed the SELECT-OPTION from the program and i am filling the batch no.

only and when i execute the program it gives the output blank.

DATA: P_AUFNR LIKE CHVW-AUFNR.

SO PLZZ TELL WHY IT IS GIVING OUTPUT BLANK?

hi,

i had made a Function Module which will reterive the production order,but when i use it in the program it gives runtime error.Plzz help me how to solve this problem.

1st i am pasting the code which i had written:-

FUNCTION ZFIND_PRDORD.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(QP_CHARG) LIKE CHVW-CHARG OPTIONAL

*" VALUE(P_AUFNR) LIKE CHVW-AUFNR OPTIONAL

*" EXPORTING

*" VALUE(P_RETVAL) LIKE CHVW-AUFNR

*"----


DATA : BEGIN OF T_CHVW OCCURS 0,

XZUGA LIKE CHVW-XZUGA,

WERKS LIKE CHVW-WERKS,

MATNR LIKE CHVW-MATNR,

CHARG LIKE CHVW-CHARG,

AUFNR LIKE CHVW-AUFNR,

EBELN LIKE CHVW-EBELN,

MBLNR LIKE CHVW-MBLNR,

ZEILE LIKE CHVW-ZEILE,

BUDAT LIKE CHVW-BUDAT,

SHKZG LIKE CHVW-SHKZG,

BWART LIKE CHVW-BWART,

MENGE LIKE CHVW-MENGE,

MEINS LIKE CHVW-MEINS,

KZBEW LIKE CHVW-KZBEW,

END OF T_CHVW.

SELECT XZUGA WERKS MATNR CHARG AUFNR EBELN

MBLNR ZEILE BUDAT SHKZG BWART MENGE MEINS KZBEW

FROM CHVW INTO TABLE T_CHVW

WHERE CHARG EQ QP_CHARG

and XZUGA = ' '

AND BWART = '101'

and aufnr eq p_aufnr

AND KZBEW = 'F' .

P_RETVAL = T_CHVW-AUFNR.

ENDFUNCTION.

Now i am displaying the program for testing this FM which gives the runtime error:-

TABLES : CHVW.

SELECT-OPTIONS : P_CHARG FOR CHVW-CHARG,

P_AUFNR FOR CHVW-AUFNR .

CALL FUNCTION 'ZFIND_PRDORD'

EXPORTING

QP_CHARG = P_CHARG

P_AUFNR = P_AUFNR

IMPORTING

P_RETVAL = P_AUFNR.

WRITE : / 'SDSQDA' .

Plzz help me out as how to solve this problem as i have to use it in

the main program.

regards,

ric.s

10 REPLIES 10
Read only

Former Member
0 Likes
1,399

Hi Ric,

1. In SE37 first execute your Function module and check with some test data's. If it is retrieve the correct data means its working fine.

2. Then try to anylyse the Runtime error. Using TRansaction ST22 you can analyse the runtime error.

3. otherwise just copy and paste the error description here.

Thanks.

Read only

Former Member
0 Likes
1,399

hi,

The problem could be ... The parameters given to the FM has to be a parameter than a select-options as select-options is a table ...

Parameters : P_CHARG like CHVW-CHARG,

P_AUFNR like CHVW-AUFNR .

CALL FUNCTION 'ZFIND_PRDORD'

EXPORTING

QP_CHARG = P_CHARG

P_AUFNR = P_AUFNR

IMPORTING

P_RETVAL = P_AUFNR.

WRITE : / 'SDSQDA' .

Regards,

Santosh

Read only

0 Likes
1,399

HI SANTOSH,

I had changed according what u said and it is not giving runtime error .

but it is not giving the value as if i send the value of batch and the prd orderr. plz tell me how do it get the output.

i had written the code of program like this:-

TABLES : CHVW.

Parameters : P_CHARG like CHVW-CHARG,

P_AUFNR like CHVW-AUFNR.

DATA: PRD LIKE CHVW-AUFNR.

CALL FUNCTION 'ZFIND_PRDORD'

EXPORTING

QP_CHARG = P_CHARG

P_AUFNR = P_AUFNR

IMPORTING

P_RETVAL = PRD.

WRITE : / PRD .

PLZ HELPMEOUT HOW TO DO THIS.

Read only

Former Member
0 Likes
1,399

hi,

Two more changes has to be made ...

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = p_aufnr

IMPORTING

OUTPUT = p_aufnr.

SELECT XZUGA WERKS MATNR CHARG AUFNR EBELN

MBLNR ZEILE BUDAT SHKZG BWART MENGE MEINS KZBEW

FROM CHVW INTO TABLE T_CHVW

WHERE CHARG EQ QP_CHARG

and XZUGA = ' '

AND BWART = '101'

and aufnr eq p_aufnr

AND KZBEW = 'F' .

if sy-subrc = 0.

read table T_CHVW index 1.

if sy-subrc = 0.

P_RETVAL = T_CHVW-AUFNR.

endif.

endif.

Regards,

Santosh

Read only

0 Likes
1,399

HI SANTOSH,

Thanks for your help.i am rewarding u for ur help .can u suggest me i have to make FM for Batches also. now should i make it in the similar way ?

moreover ,can ii have ur email-id so that in future i can have help from you.

Read only

Former Member
0 Likes
1,400

HI SANTOSH,

I had removed the SELECT-OPTION from the program and i am filling the batch no.

only and when i execute the program it gives the output blank.

DATA: P_AUFNR LIKE CHVW-AUFNR.

SO PLZZ TELL WHY IT IS GIVING OUTPUT BLANK?

Read only

0 Likes
1,399

hi,

paste the code here ...

Regards,

Santosh

Read only

0 Likes
1,399

hi santosh,

here 's d code:-

TABLES : CHVW.

PARAMETERS : P_CHARG LIKE CHVW-CHARG.

DATA: PRD LIKE CHVW-AUFNR.

DATA: P_AUFNR LIKE CHVW-AUFNR.

CALL FUNCTION 'ZFIND_PRDORD'

EXPORTING

QP_CHARG = P_CHARG

P_AUFNR = P_AUFNR

IMPORTING

P_RETVAL = PRD.

WRITE : / PRD .

when on screen i fill the batch no. noly it does not give the produciotn order no.

why it is not giving the putput?

Read only

0 Likes
1,399

hi,

It is because there are no records found in the table with blank aufnr and with the conditions given in the where condition of your select statement ... if you are looking for all the aufnr's in that case do this way ....

if not p_aufnr is initial.

SELECT XZUGA WERKS MATNR CHARG AUFNR EBELN

MBLNR ZEILE BUDAT SHKZG BWART MENGE MEINS KZBEW

FROM CHVW INTO TABLE T_CHVW

WHERE CHARG EQ QP_CHARG

and XZUGA = ' '

AND BWART = '101'

and aufnr eq p_aufnr

AND KZBEW = 'F' .

if sy-subrc = 0.

endif.

else.

SELECT XZUGA WERKS MATNR CHARG AUFNR EBELN

MBLNR ZEILE BUDAT SHKZG BWART MENGE MEINS KZBEW

FROM CHVW INTO TABLE T_CHVW

WHERE CHARG EQ QP_CHARG

and XZUGA = ' '

AND BWART = '101'

AND KZBEW = 'F' .

if sy-subrc = 0.

endif.

endif.

if not T_CHVW[] is initial.

read table T_CHVW index 1.

if sy-subrc = 0.

P_RETVAL = T_CHVW-AUFNR.

endif.

endif.

Regards,

Santosh

Read only

0 Likes
1,399

hi santosh,

thanks for your help now it is working fine i was having hint the explanation u gave but i am not dat confident.

any ways it is working fine i will reward you full 10 points for that.