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: 

select statement?

Former Member
0 Kudos

hi,

my requirement is like below.

1)i have internal table it_mat_plant.

2)select plant type from zpalnt table for the it_mat_plant-werks.

3)if plant type = 'External mfg" then delete record other wise step 4.

4) select matnr mtart from MARA table into it_mara where matnr = it_mat_plant-matnr.

please tell me how to code this requirement.

please give me sample code

thanks

satish

1 ACCEPTED SOLUTION

former_member189629
Active Contributor
0 Kudos

Hi,

Use the below code for ref...

SELECT plant type

FROM zplant

INTO TABLE it_zplant

FOR ALL ENTRIES IN it_mat_plant

WHERE werks = it_mat_plant-werks.

IF sy-subrc = 0.

DELETE it_zplant WHERE plant_type = 'External mfg'.

ENDIF.

SELECT matnr mtart

FROM mara

INTO TABLE it_mara

FOR ALL ENTRIES IN it_mat_plant

WHERE matnr = it_mat_plant-matnr.

reward if helpful,

Karthik

Message was edited by:

Karthik

3 REPLIES 3

former_member189629
Active Contributor
0 Kudos

Hi,

Use the below code for ref...

SELECT plant type

FROM zplant

INTO TABLE it_zplant

FOR ALL ENTRIES IN it_mat_plant

WHERE werks = it_mat_plant-werks.

IF sy-subrc = 0.

DELETE it_zplant WHERE plant_type = 'External mfg'.

ENDIF.

SELECT matnr mtart

FROM mara

INTO TABLE it_mara

FOR ALL ENTRIES IN it_mat_plant

WHERE matnr = it_mat_plant-matnr.

reward if helpful,

Karthik

Message was edited by:

Karthik

0 Kudos

Karthik, just to correct you.


SELECT plant type 
       FROM zplant 
       INTO TABLE it_zplant
       FOR ALL ENTRIES IN it_mat_plant
       WHERE werks = it_mat_plant-werks.
IF sy-subrc = 0.
  DELETE it_zplant WHERE plant_type = 'External mfg'.
ENDIF.

SELECT matnr mtart 
       FROM mara 
       INTO TABLE it_mara 
       for all entries in it_mat_plant " missing for all entries
       WHERE matnr = it_mat_plant-matnr.

Regards

Gopi

0 Kudos

Thanks. Infact I just edited it, by the time u replied