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: 

reg:alv grid

Former Member
0 Kudos

Hi all,

In selection screen I am taking mara-matnr.

I hav to check whether there is an entry for the field 'stlan' in mast table for the condition mast-matnr= mara-matnr and stlan =1.

If entry exists for stlan field for corresponding matnr i hav to display 'X' in alv grid otherwise 'Y' for the field 'stlan'.

Regards,

Swarna.

10 REPLIES 10

Former Member
0 Kudos

Hi,

1)Take all the entries from mast table into an internal table for selection screen matnr where mast-matnr= mara-matnr and stlan =1.

2) loop at table containing data and based on condition populate the final table which will be passed to

if gwa_mast-stlan = '1'.

pass X

else pass y to alv field.

Ad

Edited by: AD on May 6, 2009 1:46 PM

0 Kudos

Hi,

parameters:material like mara-matnr.

data:begin of itab1 occurs 0,

matnr like mast-matnr,

stlan like mast-stlan,

stlnr like mast-stlnr,

end of itab1.

data:begin of itab occurs 0,

stlnr like mast-stlnr,

end of itab.

select stlnr from mast into corresponding fields of table itab1 where matnr = material and stlan = 1.

if itab1[] is not initial.

val = 'X'.

else.

val = 'Y'.

endif.

loop at itab.

itab1-stlnr = val.

move-corresponding itab1 to itab.

endloop.

append itab.

I Passed a material which is unmatched but i am unable to display 'Y' in alv.

please check it out.

Regards,

Swarna.

0 Kudos

Because you are using loop for itab and not reading the data from itab1.

so how can you get that data ?

Take similar field in both internal tables and use read statement in loop.

0 Kudos

" if itab1[] is not initial. " upto below comment

val = 'X'.

else.

val = 'Y'.

endif. " comment this

loop at itab.

if itab1-stlnr = '1'

itab-stlnr = 'X'

else

itab-stlnr ='y'.

move-corresponding itab1 to itab.

append itab. " do before endlopp and clear variables

endloop.

Edited by: AD on May 6, 2009 2:02 PM

Former Member
0 Kudos

create a field in your alv grid with type c(1) and fill it with your results.

example:

loop your table

if tbl-stlan NE ''.

alv_grid_data-yourfield = 'Y'.

else.

alv_grid_data-yourfield = 'X'.

endif.

enloop.

regards jacko

Former Member
0 Kudos

use select query to serch the corresponding data before filling alv grid

naveen_inuganti2
Active Contributor
0 Kudos

Hi,

Make your final internal table with structure of reuired fields + 1 extra field for Y or N that should length of 1 and type of c.

Now after complition of your internal table population,

loop at itab into wa.
 if stlan is there. 
  wa-flag = 'Y'. 
 else.
  wa_flag = 'N'.
modify itab from wa.
clear wa.
endloop.

and do pass the flag fields as others into the fieldcatlog internal table.

Thanks,

Naveen Inuganti.

raviahuja
Contributor
0 Kudos

Hi,

The internal table which you are passing to the ALV Grid must contain a field for storing 'X' or 'Y' which will be filled as per the logic given above in may threads. Update that internal table first and then pass it to ALV.

Logic to Update the table would be:

SELECT stlan

FROM mast

INTO TABLE lt_mast

FOR ALL ENTRIES IN lt_mara

WHERE matnr EQ lt_mara-matnr AND

stlan EQ '1'.

I'm supposing that lt_mara is the table you are passing to ALV grid, so it would have one field stlan of size char01 AND BY DEFAULT THE VALUE WOULD BE 'X'.

Now,

LOOP AT lt_mast INTO ls_mast.

LOOP AT lt_mara INTO ls_mara WHERE matnr = ls_mast-matnr.

LS_MARA-STLAN = 'Y'.

MODIFY TABLE lt_mara FROM ls_mara.

ENDLOOP.

ENDLOOP.

Former Member
0 Kudos

Hi Swarna,

Kindly chk ..

data:

w_idx type i.

loop at itab.

w_idx = sy-tabix.

itab1-stlnr = val.

move-corresponding itab1 to itab.

modify itab index w_idx.

endloop.

append itab. // not reqd.

Regards,

Mdi.Deeba

Former Member
0 Kudos

In selection screen I am taking mara-matnr.

I hav to check whether there is an entry for the field 'stlan' in mast table for the condition mast-matnr= mara-matnr and stlan =1.

If entry exists for stlan field for corresponding matnr i hav to display 'X' in alv grid otherwise 'Y' for the field 'stlan'.

Hi,

Give condition in Start-of-selection event.

After select statement

IF mast-stlan = 1.

perform x.

else.

perform y.

in subroutine x and y print according to your condition.

Regards,

Himnashu