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

ALV Grid Display

Former Member
0 Likes
1,054

Hi folks,

Need the code for this piece of ALV req..

Required list of all materials of type u2018raw materialu2019 within the material number 1 to 100000 in plants within 1000 to 2000

Screen elements

1Material number

2plant

3Material type (validation required)

4Created on

Hi folks,

Need the code for this piece of ALV req..

Required list of all materials of type u2018raw materialu2019 within the material number 1 to 100000 in plants within 1000 to 2000

Screen elements

1Material number

2plant

3Material type (validation required)

4Created on

8 REPLIES 8
Read only

Former Member
0 Likes
1,034

Hi,

Do a validation fot the material type in AT-selection screen event.

In the start of selection, write a simple select like this:

select * from mara into table itab where matnr in s_matnr and

werks in s_werks and

matnr in s_mtart

and erdat in s_erdat.

Thanks,

Keerthi.

Read only

Former Member
0 Likes
1,034

Thanks Keerthi,

Can you give me a detailed code for this as to how th e validation is done and all.I am damn new to ABAP and i have this assignment.I need to complete it by tommorow:).The result is to be displayed in a Grid Display.

Read only

0 Likes
1,034

Hi,


REPORT  ypls_mara_test.

TABLES: mara,
        marc.

SELECT-OPTIONS: s_matnr FOR mara-matnr.
PARAMETERS:     p_mtart LIKE mara-mtart DEFAULT 'RAW'.
SELECT-OPTIONS: s_werks FOR marc-werks,
                s_ersda FOR mara-ersda.


AT SELECTION-SCREEN.
  IF p_mtart <> 'RAW'.
    "display message to correct the material type
  ENDIF.

AT SELECTION-SCREEN ON s_matnr-low.
  IF s_matnr-low IS NOT INITIAL.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = s_matnr-low
      IMPORTING
        output = s_matnr-low.


    IF s_matnr-low LT '1' OR s_matnr-low GT '100000'.
      "display error message to correct material no.
    ENDIF.
  ENDIF.

AT SELECTION-SCREEN ON s_matnr-high.
  IF s_matnr-high IS NOT INITIAL.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = s_matnr-high
      IMPORTING
        output = s_matnr-high.


    IF s_matnr-high LT '1' OR s_matnr-high GT '100000'.
      "display error message to correct material no.
    ENDIF.
  ENDIF.


" Similarly do a Check on PLANT


START-OF-SELECTION.

  SELECT a~matnr a~ersda b~werks "other fields
     into CORRESPONDING FIELDS OF TABLE itab
     FROM mara as a INNER JOIN marc as b
     on a~matnr = b~matnr
     where a~matnr in s_matnr
      and  b~werks in s_werks
      and a~ersda in s_ersda.
    
    
    
    "Pass this internal table to the REUSE_ALV_GRID_DISPLAY func.module.

Regards,

Subramanian

Read only

Former Member
0 Likes
1,034

Hi,

Your code logic wud be something like this:

SELECT a~matnr

a~ersda

a~mtart

b~werks

FROM mara AS a INNER JOIN marc AS b

ON amatnr = bmatnr

INTO TABLE t_output

WHERE A~MATNR BETWEEN 1 and 100000

AND a~mtart = 'ROH' "Raw Material

AND b~werks BETWEEN 1000 AND 2000.

After u get the values in T_OUTPUT, you can generate the ALV. Hope it helps.

Regards,

Nadim

Read only

Former Member
0 Likes
1,034

Thanks Keerthi,

Can you give me a detailed code for this as to how th e validation is done and all.I am damn new to ABAP and i have this assignment.I need to complete it by tommorow:).The result is to be displayed in a Grid Display.

Thanks Subramanyam,but can it be done w/o the function modules and the inner join??

Read only

0 Likes
1,034

Hi,

It is difficult to write the entire code here.

Please refer:

http://www.sapbrainsonline.com/

http://sap.niraj.tripod.com/id64.html

http://www.jt77.com/development1-q/

http://www.erpgenie.com/

http://www.sap-img.com

You have tonnes of ALV codes available just browse.

Regards,

Subramanian

Read only

0 Likes
1,034

Look at the sample SAP sample ALV Grid programs. Start with BCALV_GRID_DEMO, as there are others you can also look at. Best way to learn is to do it yourself.

Read only

Former Member
0 Likes
1,034

hi,

here is a sample code for ur requirement,

REPORT ZERTY.

TABLES: mara,marc.

TYPE-POOLS:SLIS.

SELECT-OPTIONS: s_matnr FOR mara-matnr obligatory.

PARAMETERS: p_mtart LIKE mara-mtart DEFAULT 'RAW'.

SELECT-OPTIONS: s_werks FOR marc-werks,

s_ersda FOR mara-ersda.

data : begin of it_mat occurs 0,

matnr type mara-matnr,

mtart type mara-mtart,

werks type marc-werks,

ersda type mara-ersda,

end of it_mat.

DATA : I_FIELDCAT TYPE slis_t_fieldcat_alv .

AT SELECTION-SCREEN.

select single * from mara where mtart = p_mtart.

if sy-subrc <> 0.

message 'Wrong Material type' type 'E'.

endif.

START-OF-SELECTION.

SELECT *

into CORRESPONDING FIELDS OF TABLE it_mat

FROM mara JOIN marc

on maramatnr = marcmatnr

where mara~matnr in s_matnr

and marc~werks in s_werks

and mara~mtart = p_mtart

and mara~ersda in s_ersda.

end-of-selection.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = 'ZERTY'

I_INTERNAL_TABNAME = 'IT_MAT'

I_INCLNAME = SY-REPID

CHANGING

ct_fieldcat = I_FIELDCAT.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZERTY'

IT_FIELDCAT = I_FIELDCAT

TABLES

t_outtab = IT_MAT.