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: 

Customer Data

Former Member
0 Kudos

Hi,

This is my module pool program. When i executing the T.code with a custoemr number that is already present, it is not retrieving the other details like name city and all.

PROGRAM ZMP_TAB1.

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • text

----


MODULE USER_COMMAND_9001 INPUT.

TABLES:

KNA1. "WORK AREA

CASE SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'DISPLAY'.

IF KNA1-KUNNR IS NOT INITIAL.

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

IF SY-SUBRC NE 0.

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

ELSE.

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

ENDIF.

ENDIF.

WHEN 'INSERT'.

INSERT KNA1.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'RECORD ALREADY EXISTS'.

ELSE.

MESSAGE S000(0) WITH 'RECORD INSERTED'.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

This is my flow logic.

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_9001.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9001.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

as far as I know KNA1 is a table and you can't use it this way...

data : zkna1 like kna1,

zkna2 like kna1.

select single * from kna1 into table zkna1.

loop at zkna1.

select single * from kna1 into table zkna2 where WHERE KUNNR = ZKNA1-KUNNR.

IF SY-SUBRC NE 0.

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

ELSE.

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

ENDIF.

ENDIF.

endloop

<b>reward points if it helps</b>

6 REPLIES 6

Former Member
0 Kudos

Hi,

as far as I know KNA1 is a table and you can't use it this way...

data : zkna1 like kna1,

zkna2 like kna1.

select single * from kna1 into table zkna1.

loop at zkna1.

select single * from kna1 into table zkna2 where WHERE KUNNR = ZKNA1-KUNNR.

IF SY-SUBRC NE 0.

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

ELSE.

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

ENDIF.

ENDIF.

endloop

<b>reward points if it helps</b>

Vijay
Active Contributor
0 Kudos

hi rams

SELECT SINGLE * FROM KNA1<b> into wa</b> WHERE KUNNR = KNA1-KUNNR." missing into and table name and wa name ie KNA1 cannot be same

and

INSERT KNA1 into ztable.

modify ztable

regards

vijay

<b>plz dont forget to reward points if useful</b>

Former Member
0 Kudos

hi,

i think you have written the logic wrong

you have not specified any work area at all to display the items.

select single * from kna1 into <work area> WHERE KUNNR = KNA1-KUNNR.

First fetch the data into work area or table and try to display it.

Thanks

Srinivas

former_member189059
Active Contributor
0 Kudos

Whenever you select data, it should have a container in which to place that selected data

this container can be a table, a field or a structure (work area) depending on your need

in your case since you are selecting a row from a table, use a work area

data: kna1_wa like kna1.
SELECT SINGLE * FROM KNA1 into kna1_wa WHERE KUNNR = KNA1-KUNNR.

Former Member
0 Kudos

How u r giving the customer numebrr??

Former Member
0 Kudos

Hello Ram,

What is your screen fields? i Guess you are using KNA1 is screen field structure.

PROGRAM ZMP_TAB1.

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • text

----


MODULE USER_COMMAND_9001 INPUT.

TABLES:

KNA1. "WORK AREA

CASE SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'DISPLAY'.

*<b>IF KNA1-KUNNR IS NOT INITIAL</b>.

if not kna1-kunnr is initial. -> this is correct statement

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

use leave to screen ur current screen.

suppose screen number is 9000.

leave to screen 9000.

IF SY-SUBRC NE 0.

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

ELSE.

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

ENDIF.

ENDIF.

WHEN 'INSERT'.

INSERT KNA1.

IF SY-SUBRC NE 0.

MESSAGE E000(0) WITH 'RECORD ALREADY EXISTS'.

ELSE.

MESSAGE S000(0) WITH 'RECORD INSERTED'.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

Try with above code

Thanks

Seshu