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

report alv

Former Member
0 Likes
482

Hi experts please help me to write the logic to the below requirement

1) Identify header materials with Material Type & Plant, Material Group , Material Number

a) Go to MARA table get the material list for material type, material group, material number equal to selection screen input .

b) go to MARC table with material list (from step a) and plant from selection screen, get the filtered list, remove the materials not satisfying selection criteria

c) get the final list of materials & bom number (STLNR) & WERKS for which BOM exists in given plant by giving list from step b, plant(WERKS ) ,usage (STLAN = 1) ,Alternative bom (STLAL =01” ) from the table MAST and

removing the materials not satisfying selection criteria

d) check BOMs from the above list are valid in STKO with the inputs STLNR , DATUV ( valid date from ) <= SY-DATUM, LOEKZ(Deletion flag) NE “X” , STLST(status) =1 (Active) and save in internal table.

remove the materials not satisfying selection criteria

2) For each material from the list in 1.d retrieve all components in the material BOM.

Using Function Module “CS_BOM_EXPL_MAT_V2”

Inputs for the function module

CAPID = ‘Z1PP’

DATUV = SY-DATUM

DELNL = X (To delete non-stockable items)

EMENG = “1”

MTNRV = material number from 1.d

MEHRS= ‘X”

RNDKZ =’1 ‘

STLAL = ‘1’

STLAN = ‘1’

WERKS = Plant from list 1.d

BREMS = ‘X’

Required information components get collected in STB table

From STB table in Function module

Get IDNRK ( component ) , OJTXP ( Component description ) , MTAR ( material type ) , MNGKO (COMP- QTY ) ,MEINS ( UNIT) DATUV ( valid from date ) , DATUB ( Valid to date )

Header material details are collected in table TOPMAT

MATNR (material number ), MAKTX ( description ) , WERK( plant ) , BMENG ( base qty) ,BME ( unit) EMENG ( required qty ) , EMG ( req qty unit )

Collect the info from FM into internal table

3)delete all material components for which MTAR is NOT EQUAL to ‘PACK’ or ‘VERPAK’ from the above internal table step 2

3) Goto CABN table get the value of ATTIN for ATNAM = “packaging type”

Goto AUSP table, get the value of ATWRT for OBJEK = IDNRK and ATINN = ATTIN from the above step and save it in internal table against each row in step 2

4) Calculate the component quantity in kg using the units of measure conversion in the material master.

For each row of internal table coming from 2 step

Use Function module MD_CONVERT_MATERIAL_UNIT & convert component Quantities into Kg

I_MATNR = IDNRK ( From the internal table step 2 .)

I_IN_ME = MEINS (( From the internal table step 2 )

I_OUT_ME = “KG” (always)

I_MENGE = MNGKO (From the internal table step 2 .)

Get E_MENGE and update in the internal table (2) against each component

Also pass this value against FACTOR

Note: Since EMENG = “1” in step 2 while exploding bom the quantity E_MENGE will be equal to factor . no need to divide the quantity with base quantity

with regards

serma

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
434

Use this logic

&----


*& Report ZDEMO_ALVGRID *

*& *

&----


*& *

*& Example of a simple ALV Grid Report with grand total *

*& ................................... *

*& *

*& The basic requirement for this demo is to display a number of *

*& fields from the EKKO table. *

&----


REPORT zdemo_alvgrid .

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'. "Display column total

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

  • to make editable field

  • fieldcatalog-edit = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

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. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

endform. " DATA_RETRIEVAL

Reward points helpful........

Rajneesh Gupta

Hi experts please help me to write the logic to the below requirement

1) Identify header materials with Material Type & Plant, Material Group , Material Number

a) Go to MARA table get the material list for material type, material group, material number equal to selection screen input .

b) go to MARC table with material list (from step a) and plant from selection screen, get the filtered list, remove the materials not satisfying selection criteria

c) get the final list of materials & bom number (STLNR) & WERKS for which BOM exists in given plant by giving list from step b, plant(WERKS ) ,usage (STLAN = 1) ,Alternative bom (STLAL =01” ) from the table MAST and

removing the materials not satisfying selection criteria

d) check BOMs from the above list are valid in STKO with the inputs STLNR , DATUV ( valid date from ) <= SY-DATUM, LOEKZ(Deletion flag) NE “X” , STLST(status) =1 (Active) and save in internal table.

remove the materials not satisfying selection criteria

2) For each material from the list in 1.d retrieve all components in the material BOM.

Using Function Module “CS_BOM_EXPL_MAT_V2”

Inputs for the function module

CAPID = ‘Z1PP’

DATUV = SY-DATUM

DELNL = X (To delete non-stockable items)

EMENG = “1”

MTNRV = material number from 1.d

MEHRS= ‘X”

RNDKZ =’1 ‘

STLAL = ‘1’

STLAN = ‘1’

WERKS = Plant from list 1.d

BREMS = ‘X’

Required information components get collected in STB table

From STB table in Function module

Get IDNRK ( component ) , OJTXP ( Component description ) , MTAR ( material type ) , MNGKO (COMP- QTY ) ,MEINS ( UNIT) DATUV ( valid from date ) , DATUB ( Valid to date )

Header material details are collected in table TOPMAT

MATNR (material number ), MAKTX ( description ) , WERK( plant ) , BMENG ( base qty) ,BME ( unit) EMENG ( required qty ) , EMG ( req qty unit )

Collect the info from FM into internal table

3)delete all material components for which MTAR is NOT EQUAL to ‘PACK’ or ‘VERPAK’ from the above internal table step 2

3) Goto CABN table get the value of ATTIN for ATNAM = “packaging type”

Goto AUSP table, get the value of ATWRT for OBJEK = IDNRK and ATINN = ATTIN from the above step and save it in internal table against each row in step 2

4) Calculate the component quantity in kg using the units of measure conversion in the material master.

For each row of internal table coming from 2 step

Use Function module MD_CONVERT_MATERIAL_UNIT & convert component Quantities into Kg

I_MATNR = IDNRK ( From the internal table step 2 .)

I_IN_ME = MEINS (( From the internal table step 2 )

I_OUT_ME = “KG” (always)

I_MENGE = MNGKO (From the internal table step 2 .)

Get E_MENGE and update in the internal table (2) against each component

Also pass this value against FACTOR

Note: Since EMENG = “1” in step 2 while exploding bom the quantity E_MENGE will be equal to factor . no need to divide the quantity with base quantity

with regards

serma

1 REPLY 1
Read only

Former Member
0 Likes
435

Use this logic

&----


*& Report ZDEMO_ALVGRID *

*& *

&----


*& *

*& Example of a simple ALV Grid Report with grand total *

*& ................................... *

*& *

*& The basic requirement for this demo is to display a number of *

*& fields from the EKKO table. *

&----


REPORT zdemo_alvgrid .

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'. "Display column total

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

  • to make editable field

  • fieldcatalog-edit = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

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. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

endform. " DATA_RETRIEVAL

Reward points helpful........

Rajneesh Gupta