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: 

hI

Former Member
0 Kudos
361

Hi,

Iam getting the error at the block letters. Plz let me what is correct syntax.

PROGRAM ZMP_TAB2.

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'.

<b>MOVE CORRESPONDING FIELDS FROM ST_KNA1 TO KNA1.</b>

INSERT KNA1.

IF SY-SUBRC EQ 0.

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

ELSE.

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

ENDIF.

CLEAR ST_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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
250

Its MOVE-CORRESPONDING

8 REPLIES 8

Former Member
0 Kudos
251

Its MOVE-CORRESPONDING

Former Member
0 Kudos
250

It is

MOVE-CORRESPONDING FIELDS FROM ST_KNA1 TO KNA1.

Thanks

Seshu

Former Member
0 Kudos
250

Hi,

Just use MOVE-CORRESPONDING ST_KNA1 TO KNA1.

Vijay
Active Contributor
0 Kudos
250

hi rams

<b>MOVE-CORRESPONDING FIELDS OF ST_KNA1 TO KNA1.</b>

regards

vijay

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

0 Kudos
250

Hi,


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 FROM ST_KNA1 TO KNA1. " THe problem is here you should be using MOVE-CORRESPONDING. 
INSERT KNA1.
IF SY-SUBRC EQ 0.
MESSAGE S000(0) WITH 'CUSTOMER RECORD INSERTED'.
ELSE.
MESSAGE E000(0) WITH 'CUSTOMER RECORD NOT INSERTED'.
ENDIF.
CLEAR ST_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 

Regards,

Sesh

Former Member
0 Kudos
250

MOVE-CORRESPONDING ST_KNA1 TO KNA1.

Former Member
0 Kudos
250

use...

<b>MOVE-CORRESPONDING ST_KNA1 TO KNA1</b>

Former Member
0 Kudos
250

MOVE-CORRESPONDING

Basic form

MOVE-CORRESPONDING rec1 TO rec2.

Effect

Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines.

Searches for the sub-fields which occur both in rec1 and rec2 and then generates, for all relevant field pairs which correspond to the sub-fields ni , statements of the form

MOVE rec1-ni TO rec2-ni.

The other fields remain unchanged.

With complex structures, the full names of the corresponding field pairs must be identical.

Example

DATA: BEGIN OF INT_TABLE OCCURS 10,

WORD(10),

NUMBER TYPE I,

INDEX LIKE SY-INDEX,

END OF INT_TABLE,

BEGIN OF RECORD,

NAME(10) VALUE 'not WORD',

NUMBER TYPE I,

INDEX(20),

END OF RECORD.

...

MOVE-CORRESPONDING INT_TABLE TO RECORD.

This MOVE-CORRESPONDING statement is equivalent to both the following statements:

MOVE INT_TABLE-NUMBER TO RECORD-NUMBER.

MOVE INT_TABLE-INDEX TO RECORD-INDEX.

Example

TYPES: BEGIN OF ROW1_3,

CO1 TYPE I,

CO2 TYPE I,

CO3 TYPE I,

END OF ROW1_3.

TYPES: BEGIN OF ROW2_4,

CO2 TYPE I,

CO3 TYPE I,

CO4 TYPE I,

END OF ROW2_4.

TYPES: BEGIN OF MATRIX1,

R1 TYPE ROW1_3,

R2 TYPE ROW1_3,

R3 TYPE ROW1_3,

END OF MATRIX1.

TYPES: BEGIN OF MATRIX2,

R2 TYPE ROW2_4,

R3 TYPE ROW2_4,

R4 TYPE ROW2_4,

END OF MATRIX2.

DATA: ROW TYPE ROW1_3,

M1 TYPE MATRIX1,

M2 TYPE MATRIX2.

ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3.

MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3.

MOVE-CORRESPONDING M1 TO M2.

The last MOVE-CORRESPONDING statement is equivalent to the statements:

MOVE: M1-R2-CO2 TO M2-R2-CO2,

M1-R2-CO3 TO M2-R2-CO3,

M1-R3-CO2 TO M2-R3-CO2,

M1-R3-CO3 TO M2-R3-CO3.