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

Reg : select query

Former Member
0 Likes
420

Hi all the requirement is as follows .in the first select query we select the records from the z table based on the plant entered on the selection screen into internal table itab_table3.After that in the internal table there might be material number entries with * so i have to take all the materials corresponding to the material type .the second select query is written for that only .i am deleting all the records wherever exclude indicator is x . but now the requirement is that i need to delete the records when material number is not equal to * .bcoz all the records are fetched corresponding to the single material type .

*--Querying the table3 for plant entered on selection screen and

*--getting material no. and type

SELECT werks mtart matnr exclude INTO TABLE

itab_table3 FROM zwm_tbl_mat_alog WHERE werks IN s_werks.

LOOP AT itab_table3 INTO wa_exclude WHERE exclude EQ ' '.

MOVE wa_exclude TO itab_exclude.

APPEND itab_exclude .

CLEAR wa_exclude.

ENDLOOP.

*--Filtering out the records which are obtained from table3

IF sy-subrc EQ 0.

IF NOT itab_table3[] IS INITIAL.

SELECT maramatnr maramtart

mchbwerks mchbcharg mchb~clabs

INTO CORRESPONDING FIELDS OF TABLE itab_mchb_join

FROM mara AS mara JOIN mchb AS mchb

ON maramatnr = mchbmatnr

FOR ALL ENTRIES IN itab_exclude

WHERE mtart = itab_exclude-mtart

AND werks IN s_werks.

ENDIF.

ENDIF.

LOOP AT itab_table3 WHERE exclude EQ 'X'.

DELETE itab_mchb_join WHERE matnr = itab_table3-matnr.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
392

HI ambarish,

I understand that your requirement has changed now as earlier you have to check teh indicator but now that is not required....

So what you can do now is :-

In the first select query ,select the records from the z table based on the plant entered on the selection screen into internal table itab_table3.

After that in the internal table there might be manyentries with so i have to take all the materials corresponding to the material type .the second select query should be written for that.

Now READ that table and delete the entries where the material number is not *.

Best of luck,

Bhumika

2 REPLIES 2
Read only

Former Member
0 Likes
393

HI ambarish,

I understand that your requirement has changed now as earlier you have to check teh indicator but now that is not required....

So what you can do now is :-

In the first select query ,select the records from the z table based on the plant entered on the selection screen into internal table itab_table3.

After that in the internal table there might be manyentries with so i have to take all the materials corresponding to the material type .the second select query should be written for that.

Now READ that table and delete the entries where the material number is not *.

Best of luck,

Bhumika

Read only

0 Likes
392

HI

Follow like this,

Create one more internal table with the same structure where you are getting the values,

Follow the logic like this.

DATA :STR1 type string value '*'.

Loop at itab1 into wa_itab1.

if wa_itab1-matnr CA STR1.

move wa_itab1 to wa_itab2.

append wa_itab2 to it_itab2.

endif.

endloop.

Then you will get the desired values in the it_itab2 table.

Hope this will helpfull for you,

Regards,

KP

Edited by: krishna prasad on Aug 14, 2008 9:19 AM

Edited by: krishna prasad on Aug 14, 2008 9:19 AM