2007 Sep 19 8:11 AM
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
2007 Sep 19 10:42 AM
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.
2007 Sep 19 8:18 AM
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
2007 Sep 19 8:26 AM
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
2007 Sep 19 8:31 AM
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
2007 Sep 19 8:36 AM
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
2007 Sep 19 10:42 AM
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.