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

Inserting Customer

Former Member
0 Likes
546

Hi,

I am trying to insert the customers using this Module pool program.

Please let me know the mistakes in this code.

  • LINE TYPES.

TYPES:

BEGIN OF TY_KNA1,

KUNNR TYPE KNA1-KUNNR,

LAND1 TYPE KNA1-LAND1,

NAME1 TYPE KNA1-NAME1,

ORT01 TYPE KNA1-ORT01,

TELF1 TYPE KNA1-TELF1,

END OF TY_KNA1.

DATA:

ST_KNA1 TYPE TY_KNA1.

&----


*& Module USER_COMMAND_9001 INPUT

&----


  • text

----


MODULE USER_COMMAND_9001 INPUT.

CASE SY-UCOMM.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'INSERT'.

MOVE CORRESPONDING FILEDS OF ST_KNA1 TO KNA1.

INSERT KNA1.

IF SY-SUBRC EQ 0.

MESSAGE S000(0) WITH 'CUSTOMER RECORD INSERTED'.

ELSE.

MESSAGE S000(0) WITH 'CUSTOMER RECORD NOT INSERTED'.

ENDIF.

CLEAR ST_KNA1,KNA1.

WHEN 'DISPLAY'.

SELECT SINGLE * KUNNR LAND1 NAME1 ORT01 TELF1 FROM KNA1 INTO ST_KNA1

WHERE KUNNR EQ ST_KNA1-KUNNR.

IF SY-SUBRC NE 0.

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

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

Thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
513

Hi,

MOVE CORRESPONDING FIELDS OF ST_KNA1 TO KNA1.

instead of

MOVE CORRESPONDING FILEDS OF ST_KNA1 TO KNA1.

Read only

Former Member
0 Likes
513

INSERT KNA1.

If you want to know why. Ask me. Oh please ask me.

Read only

prasanth_kasturi
Active Contributor
0 Likes
513

hiiii

if you use insert before display

after inserting the value you are clearing the work area,

so no value will be in ST_KNA1-KUNNR

so pass this value to a variable before clearing and you can use it in where condition

MOVE CORRESPONDING FILEDS OF ST_KNA1 TO KNA1.

and

speling mistake for fields you wrote fileds