2009 May 05 12:31 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.
2009 May 05 12:46 PM
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
2009 May 05 12:35 PM
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
2009 May 05 12:44 PM
Hi,
Can you please tell me the statement for which I have to display the field as 'X' in grid.
Thanks,
Usha.
2009 May 05 12:48 PM
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.
2009 May 05 12:38 PM
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.
2009 May 05 12:46 PM
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
2009 May 05 1:19 PM
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
2009 May 05 1:38 PM
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
2009 May 05 1:45 PM
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
2009 May 05 1:45 PM
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.
2009 May 05 1:50 PM
Hi Usha Rani,
There won't be no material created with out discription...that's why SPACE is not moving.
Thanks
Karthik
2009 May 05 1:47 PM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |