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:ALV

Former Member
0 Likes
1,435

Hi all,

Ooodevening.

In selection-screen I am taking matnr from makt table.

I want to pick MAKTX field from makt table and display it in grid.

for that my requirement is:

If makt-matnr = mara-matnr,then I want to disply MAKTX field in grid as 'X' else ' '.

Please tell me the query for this.

Thanks and Regards,

Usha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,411

Hi,

If maktx value is there (description) is there it should be displayed,else it should not be displayed.

Is that you trying to ask ?.

Select * from mara into corresponding fields of table itab where matnr in s_matnr.
loop at itab.
select single maktx from makt into itab-maktx where matnr = itab-matnr.
modify itab.
endloop.

 loop at itab.
if not itab-maktx is initial.
move 'X' to itab-maktx.
else.
move ' ' to itab-maktx.
endif.
modify itab.
endloop.

Regards,

Bathri.

Edited by: Bathrinath Sankaranarayanan on May 5, 2009 1:48 PM

Edited by: Bathrinath Sankaranarayanan on May 5, 2009 1:53 PM

Hi all,

Ooodevening.

In selection-screen I am taking matnr from makt table.

I want to pick MAKTX field from makt table and display it in grid.

for that my requirement is:

If makt-matnr = mara-matnr,then I want to disply MAKTX field in grid as 'X' else ' '.

Please tell me the query for this.

Thanks and Regards,

Usha.

11 REPLIES 11
Read only

Former Member
0 Likes
1,411

Hi

For materials MARA is a base table and no material will exist in other tables which is not in MARA.

In u r case u can fill 'X' for all materials.

Kiran

Edited by: kiran vempati on May 5, 2009 1:41 PM

Read only

0 Likes
1,411

Hi,

Can you please tell me the statement for which I have to display the field as 'X' in grid.

Thanks,

Usha.

Read only

0 Likes
1,411

Hi,

Please tell me the code to display as per my requirement as I am new to SAP.

My requirement is:

Input:makt-matnr .

pick maktx by passing makt-matnr.

if makt-matnr = mara-matnr

then makt-maktx='X'

else

makt-maktx=' '

I hav to display either 'X' or ' ' in grid.

Thanks,

Usha.

Read only

Former Member
0 Likes
1,411

Hi,

Not clear what your requirement is.

But as far as i have understood i think you keep this condition while declaring the field catalog..

If the condition satisfies it will declare a filed catalog or else another...

Regards.

Read only

Former Member
0 Likes
1,412

Hi,

If maktx value is there (description) is there it should be displayed,else it should not be displayed.

Is that you trying to ask ?.

Select * from mara into corresponding fields of table itab where matnr in s_matnr.
loop at itab.
select single maktx from makt into itab-maktx where matnr = itab-matnr.
modify itab.
endloop.

 loop at itab.
if not itab-maktx is initial.
move 'X' to itab-maktx.
else.
move ' ' to itab-maktx.
endif.
modify itab.
endloop.

Regards,

Bathri.

Edited by: Bathrinath Sankaranarayanan on May 5, 2009 1:48 PM

Edited by: Bathrinath Sankaranarayanan on May 5, 2009 1:53 PM

Read only

0 Likes
1,411

Hi ,

The if statement is working to display 'X' in the grid if match is found but if i give an unmatched matnr i am not able to display space ( ' ' )

Waiting for ur valuable reply

Regards,

Usha

Read only

0 Likes
1,411

Hi,

In this case u r checking maramatnr with maktmatnr.In this condition it will only display

records which satisfies this condition ie where maramatnr = maktmatnr else if the condition

does not satisfies it wont fetch.

Please tell me exact requirement so that i could help u.

Regards,

Bathri

Read only

0 Likes
1,411

hi,

See the below pseudo code.


TYPE-POOLS slis.

DATA : it_mara TYPE TABLE OF mara WITH HEADER LINE,
       it_mak TYPE TABLE OF makt WITH HEADER LINE,
       
       BEGIN OF it_itab OCCURS 1,
       matnr TYPE mara-matnr,
       maktx TYPE makt-maktx,
       char,
       END OF it_itab,

       it_fcat TYPE slis_t_fieldcat_alv,
       wa_fcat TYPE slis_fieldcat_alv.

START-OF-SELECTION.
  PERFORM prepare_fieldcat.
  PERFORM fetch_data.

END-OF-SELECTION.
  PERFORM match_internaltables.
  BREAK-POINT.
  PERFORM displaydata.
  
*&---------------------------------------------------------------------*
*&      Form  prepare_fieldcat
*&---------------------------------------------------------------------*
FORM prepare_fieldcat .
  ADD 1 TO wa_fcat-col_pos.
  wa_fcat-fieldname = 'MATNR'.
  wa_fcat-seltext_m = 'Material Number'.
  APPEND wa_fcat TO it_fcat.

  ADD 1 TO wa_fcat-col_pos.
  wa_fcat-fieldname = 'MAKTX'.
  wa_fcat-seltext_m = 'Material Description'.
  APPEND wa_fcat TO it_fcat.

  ADD 1 TO wa_fcat-col_pos.
  wa_fcat-fieldname = 'CHAR'.
  wa_fcat-seltext_m = 'Status'.
  APPEND wa_fcat TO it_fcat.
ENDFORM.                    " prepare_fieldcat

*&---------------------------------------------------------------------*
*&      Form  fetch_data
*&---------------------------------------------------------------------*
FORM fetch_data .
  SELECT * FROM mara INTO TABLE it_mara .
  SELECT * FROM makt INTO TABLE it_mak  WHERE spras = sy-langu .

  SORT it_mara BY matnr.
  SORT it_mak BY matnr.
ENDFORM.                    " fetch_data

*&---------------------------------------------------------------------*
*&      Form  match_internaltables
*&---------------------------------------------------------------------*
FORM match_internaltables .
  LOOP AT it_mara.
    it_itab-matnr = it_mara-matnr.
    READ TABLE it_mak[] INTO it_mak WITH KEY matnr = it_mara-matnr.
    it_itab-maktx = it_mak-maktx.
    IF sy-subrc = 0.
      it_itab-char = 'X'.
    ELSE.
      it_itab-char = ' '.
    ENDIF.
    APPEND it_itab.
  ENDLOOP.
ENDFORM.                    " match_internaltables

*&---------------------------------------------------------------------*
*&      Form  displaydata
*&---------------------------------------------------------------------*
FORM displaydata .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
      it_fieldcat        = it_fcat
    TABLES
      t_outtab           = it_itab
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " displaydata

Thanks & Regards

Read only

0 Likes
1,411

Hi,

Yes,You are correct.

In case of unmatched records I want to display space in the grid.This is my requirement.

Please help me.

Thanks,

Usha.

Read only

0 Likes
1,411

Hi Usha Rani,

There won't be no material created with out discription...that's why SPACE is not moving.

Thanks

Karthik

Read only

Former Member
0 Likes
1,411

Hi Rani,

kindly chk hpe it helps.....

 
data: t_itab type table of makt.
data: t_itab2 type table of mara.
data w_idx type i.

select maktx
from makt
into corresponding fields of t_itab
where matnr in s_matnr.

loop at t_itab.
w_idx = sy-tabix.
  select single matnr  from mara into t_itab2 where matnr = t_itab-matnr.
  if sy-subrc eq 0.
     t_itab-maktx = 'X'.
   modify t_itab index w_idx.
     clear t_itab.
 else.
    t_itab-maktx = space.
    modify t_itab index w_idx.
 endif.
endloop.

Regards.