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: 

selection issue

Former Member
0 Kudos

Dear all ,

i want to select some fields from this tables (MARA - MAKT - T023T - MARC - MARD - MBEW )

i created internal tables and structure for each one , selected from MARA into ITAB1

and select another fields from another tables and loop at itab1 and read table but my layout is duplicated data and some fields not read .. why ??

Edited by: emanflower on Sep 22, 2011 11:05 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Please make use of joins to select particular fields from different tables. Once data is retrieved, sort it based on material number and then delete the adjacent duplicates.

Further, loop at your internal table to read data from the text tables to get material descriptions and append to final internal table.

Regards,

Danish.

13 REPLIES 13

Former Member
0 Kudos

My Code :

<removed by moderator>

Moderator message: please post only relevant code parts, your posts must contain less than 5000 characters to preserve readable formatting.

Edited by: Thomas Zloch on Sep 22, 2011 11:19 AM

deepak_dhamat
Active Contributor
0 Kudos

Hi ,

Nobody will be able to help with Your Virtual Selection .

Be clear with your Question . What you are Expecting? .

regards

deepak.

Former Member
0 Kudos

Hi,

Please make use of joins to select particular fields from different tables. Once data is retrieved, sort it based on material number and then delete the adjacent duplicates.

Further, loop at your internal table to read data from the text tables to get material descriptions and append to final internal table.

Regards,

Danish.

0 Kudos
        • get material no. & material group

SELECT MATNR

MATKL "Material Group

BISMT "Old material number

MEINS "Base Unit of Measure

MTART "Material Type

INTO CORRESPONDING FIELDS OF TABLE itab

FROM mara

WHERE matnr IN S_MATNR

  • AND MTART = ITAB-MTART .

and MTART = 'ERSA' OR MTART ='IERS'.

LOOP AT itab.

SHIFT itab-matnr LEFT DELETING LEADING '0'.

MODIFY itab.

ENDLOOP.

***get safety stock & reorder point

SELECT MATNR "Material Number

EISBE "Safety Stock

MINBE "Reorder Point

WERKS "PLANT

INTO TABLE IT_MARC

FROM MARC

  • FOR ALL ENTRIES IN ITAB

WHERE matnr = itab-matnr

AND WERKS = P_WERKS.

***get Unrestricted & storage location

SELECT LABST "Valuated Unrestricted-Use Stock

MATNR

WERKS

LGORT "Storage Location

INTO TABLE IT_MARD

FROM MARD

  • FOR ALL ENTRIES IN ITAB

WHERE matnr = itab-matnr

AND WERKS = P_WERKS.

      • get material discription

SELECT matnr

MAKTX "material Disc.

INTO TABLE it_makt

FROM MAKT

  • FOR ALL ENTRIES IN itab

where spras = sy-langu

AND matnr = itab-matnr.

***get mat grp desc.

SELECT MATKL wgbez "Material Group Description

FROM t023t

INTO TABLE it_t023t

  • FOR ALL ENTRIES IN itab

WHERE matkl = itab-matkl

and spras = sy-langu.

**Get unit Price (EGP)

SELECT MATNR

VERPR "Unit Price

SALK3 "Value of Total Valuated Stock

FROM MBEW

INTO TABLE IT_MBEW

  • FOR ALL ENTRIES IN ITAB

WHERE matnr = itab-matnr.

***Get

  • SELECT MENGE "Quantity

  • BWTAR "Valuation Type

    • MBLNR

  • FROM MSEG

  • INTO TABLE IT_MSEG

  • FOR ALL ENTRIES IN ITAB

  • WHERE MBLNR = itab-MBLNR.

LOOP AT ITAB .

G_TABIX = SY-TABIX.

LOOP AT IT_MARD INTO GS_MARD.

READ TABLE IT_MARA INTO GS_MARA WITH KEY MATNR = GS_MARD-MATNR.

IF SY-SUBRC EQ 0.

MOVE-CORRESPONDING GS_MARA TO GS_ITAB.

READ TABLE IT_T023T INTO GS_T023T WITH KEY MATKL = GS_MARA-MATKL.

IF SY-SUBRC EQ 0.

GS_ITAB-WGBEZ = GS_T023T-WGBEZ.

ENDIF.

ENDIF.

ENDLOOP.

READ TABLE IT_MARC INTO GS_MARC WITH KEY MATNR = GS_MARD-MATNR

WERKS = GS_MARD-WERKS.

IF SY-SUBRC EQ 0.

GS_ITAB-EISBE = GS_MARC-EISBE.

GS_ITAB-MINBE = GS_MARC-MINBE .

ENDIF.

READ TABLE IT_MAKT INTO GS_MAKT WITH KEY MATNR = GS_MARD-MATNR.

IF SY-SUBRC EQ 0.

GS_ITAB-MAKTX = GS_MAKT-MAKTX.

ENDIF.

APPEND GS_ITAB TO ITAB SORTED BY matnr .

CLEAR : GS_MARD , GS_t023t ,GS_MARC,GS_MAKT, GS_ITAB .

0 Kudos

Comment this piece of code and try again


LOOP AT itab.
SHIFT itab-matnr LEFT DELETING LEADING '0'.
MODIFY itab.
ENDLOOP.

0 Kudos

Dear Arseni Gallardo

thanks for replay but the same issue

some fields in another select (not big select ) not read data ??

0 Kudos

Dear Danish2285

thanks but can u write this code to know How ??

Thanks again

0 Kudos

You need to go on an ABAP course and people should not be wasting their time with such simple issues .

0 Kudos

Hi,

I guess I have given you the pseudo code to write your program. Please try. Also, make use of real time debugging i.e. /h.

Debugging really helps you find out where you are going wrong.

Make use of joins. If you are using FOR ALL ENTRIES IN, don't forget to give sy-subrc check.

Regards,

Danish.

Former Member
0 Kudos

Hi,

Check below code...

tables: MARA , MAKT, T023T, MARC, MARD, MBEW .

  • Here we will get error message as 'MANDT' already exits. so we should declare fields with respect to tables.

  • But I am including tables directly here. you will change internal as per your requirement.

TYPES begin of ty_final.

include structure MARA.

include structure MAKT.

include structure T023T.

include structure MARC.

include structure MARD.

include structure MBEW.

TYPES end of ty_final.

  • Internal table

data: t_t023t type standard table of t023t,

t_mara type standard table of mara with header line,

t_makt type standard table of makt with header line,

t_marc type standard table of marc with header line,

t_mard type standard table of mard with header line,

t_mbew type standard table of mbew with header line,

t_final type table of ty_final.

  • work area

data: wa_t023t type t023t,

wa_final type ty_final.

select-options s_matnr for mara-matnr.

start-of-selection.

select * from mara into table t_mara where matnr = s_matnr.

if sy-subrc = 0.

select * from t023 into table t_t023

for all entries in t_mara where maktl = t_mara-maktl.

select * from makt into table t_makt

for all entries in t_mara where matnr = t_mara-matnr.

select * from marc into table t_marc

for all entries in t_mara where matnr = t_mara-matnr.

select * from mard into table t_mard

for all entries in t_mara where matnr = t_mara-matnr.

select * from mbew into table t_mbew

for all entries in t_mara where matnr = t_mara-matnr.

endif.

delete adjaucent duplicates from t_t023t comparing all.

loop at t_mara.

read t_marc with key matnr = t_mara-matnr.

if sy-subrc = 0.

move-corresponding t_marc into wa_final.

endif.

read t_makt with key matnr = t_mara-matnr.

if sy-subrc = 0.

move-corresponding t_makt into wa_final.

endif.

read t_makt with key matnr = t_mara-matnr.

if sy-subrc = 0.

move-corresponding t_makt into wa_final.

endif.

read t_mard with key matnr = t_mara-matnr.

if sy-subrc = 0.

move-corresponding t_mard into wa_final.

endif.

read t_mbew with key matnr = t_mara-matnr.

if sy-subrc = 0.

move-corresponding t_mbew into wa_final.

endif.

read t_t023 with key maktl = t_mara-maktl.

if sy-subrc = 0.

move-corresponding t_t023t into wa_final.

endif.

move-corresponding t_mara to wa_final.

append wa_final to t_final.

clear t_mara.

endloop.

Ram.

0 Kudos

Ram,

That is just the worst code ever. Maybe you should go on an ABAP course also.

0 Kudos

Hi ,

@ram: THis is not good method of coding ,

Other person whom you are telling , he will get more confused and Afraid .

You have included all tables in Single work area .

regards

deepak.

Edited by: Deepak Dhamat on Sep 22, 2011 1:25 PM

0 Kudos

This code not read any data

but my code is read some fields not all fields i need .

thanks all to try help me .