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: 

Module pool Program

Former Member
0 Kudos
172

Hi,

This is my module pool program.

When iam executing this using t.code data of the customer was not retrieved.

Plz let me know where i had gone wrong.

MODULE USER_COMMAND_9001 INPUT.

TABLES:

KNA1.

CASE SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'DISPLAY'.

IF KNA1-KUNNR IS NOT INITIAL.

SELECT SINGLE * FROM KNA1 WHERE KUNNR EQ KNA1-KUNNR.

ENDIF.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'CUSTOMER NUMBER INVALID'.

ELSE.

MESSAGE E000(0) WITH 'INPUT CUSTOMER NUMBER'.

ENDIF.

WHEN 'INSERT'.

INSERT KNA1.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'RECORD INSERTED'.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

1 ACCEPTED SOLUTION

Former Member
0 Kudos
126

Hi ram,

Dont use error message if u want the processing to continue. [and r u fetching the kunnr into kna1?...]

instead use'i' (information) message:

I guess u r getting a n error message which says ''INPUT CUSTOMER NUMBER'' and no data is fetch.

If I am correct then , change the error message to 'i'

WHEN 'DISPLAY'.

IF KNA1-KUNNR IS NOT INITIAL.

SELECT SINGLE * FROM KNA1 WHERE KUNNR EQ KNA1-KUNNR.

ENDIF.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'CUSTOMER NUMBER INVALID'.

ELSE.

MESSAGE i000(0) WITH 'INPUT CUSTOMER NUMBER'.

ENDIF.

5 REPLIES 5

Former Member
0 Kudos
126

Hi rams,

there is nothing wrong with ur module pool program what are you passing kna1-kunnr.

Execute it in debug mode and check why data is not retreived.

Regards,

Ravi G

Former Member
0 Kudos
126

In this program

when 'display'

you are checking the kna1-kunnr

check weather you have to pick the value from any internal table

if you check the kna1-kunnr initially

you will not get any value

the value will be always initial

so you can not fetch any value back from the table

you just make it as

select single * from kna1 where kunnr EQ itab-kunnr or some thing variable v_kunnr.

if you select using kna1-kunnr you will not get any value there

former_member196299
Active Contributor
0 Kudos
126

hi Rams ,

I am a bit confused for your code , did you do a syntax check on this code ?

I guess you have missed out the INTO clause in your SELECT statement .

There are no structure or I-table where you are storing the values from KNA1 table .Please check that .

Regards,

Ranjita

Former Member
0 Kudos
126

Hi rams,

I think the logic is to be corrected,

You are checking for sy-subrc ryt !!! that shud be done inside the

if condition itself as shown below !! the below code will give you an idea

...


IF KNA1-KUNNR IS NOT INITIAL.
SELECT SINGLE * FROM KNA1 WHERE KUNNR EQ KNA1-KUNNR.
******ENDIF.
    IF SY-SUBRC NE 0.
        MESSAGE E000(0) WITH 'CUSTOMER NUMBER INVALID'.
    ELSE.
        MESSAGE E000(0) WITH 'CUSTOMER NUMBER EXISTS'.
    ENDIF.

ELSE.
MESSAGE E000(0) WITH 'INPUT CUSTOMER NUMBER'.
ENDIF.

ENDIF.

Happy coding ...

Regards,

SJ

Former Member
0 Kudos
127

Hi ram,

Dont use error message if u want the processing to continue. [and r u fetching the kunnr into kna1?...]

instead use'i' (information) message:

I guess u r getting a n error message which says ''INPUT CUSTOMER NUMBER'' and no data is fetch.

If I am correct then , change the error message to 'i'

WHEN 'DISPLAY'.

IF KNA1-KUNNR IS NOT INITIAL.

SELECT SINGLE * FROM KNA1 WHERE KUNNR EQ KNA1-KUNNR.

ENDIF.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'CUSTOMER NUMBER INVALID'.

ELSE.

MESSAGE i000(0) WITH 'INPUT CUSTOMER NUMBER'.

ENDIF.