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

EBELN

Former Member
0 Likes
5,253

hI EVERYBODY ,

To generate double click on a field

THANKS.

HEMA.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,974

Hi,

The changes are marked in bold...I copied the code from your post and made the changes..

Just copy the changes as mentioned..

I have done the user command for both the ALV FMs..

Please go through till the end of the code..

I have added a subroutine USER_COMMAND1..

ables: t001, " Company Codes

t001w, " Plants/Branches

lfa1, " Vendor Master

ska1, " GL Account Master

mara, " Material Master

ekko, " PO Header Data

cska, " Cost Elements

csks, " Cost Centers

bsis, " GL Accounts: Open Items Data

bkpf. " Accounting Doc: Header Data

type-pools : slis.

data: g_repid like sy-repid,

g_exit type c,

g_events type slis_t_event,

g_list_top_of_page type slis_t_listheader,

g_exit_caused_by_caller,

g_exit_caused_by_user type slis_exit_by_user,

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_variant like disvariant,

g_variant1 like disvariant, " To store variant - OS0160

g_var_save type c value 'A', " Save - OS0160

g_var_exit type c, " Exit - OS0160

g_save.

constants : c_x type c value 'X', " Flag

c_c type c value 'C', " Flag

c_l type c value 'L', " Flag

c_a type c value 'A', " Line Type

c_h type c value 'H', " Dr/Cr

c_s type c value 'S', " Line Type

c_mkpf(4) type c value 'MKPF', " Table

c_save type c value 'U', " OS0160

c_mat_obj like znablackbx-obj_id

value 'CIMMATNR'. "Object Id OS0335

data: begin of i_bsis occurs 0,

bukrs like bsis-bukrs, " Company Code

hkont like bsis-hkont, " GR IR Account

gjahr like bsis-gjahr, " Fiscal Year

belnr like bsis-belnr, " Acc Document

buzei like bsis-buzei, " Item No

budat like bsis-budat, " Receipt Date(Posting)

monat like bsis-monat, " Period

end of i_bsis.

data: begin of i_bseg occurs 0,

bukrs like bsis-bukrs, " Company Code

belnr like bsis-belnr, " Acc Document

  • buzei like bsis-buzei, " Item No "Comment CR 47607

gjahr like bsis-gjahr, " Fiscal Year

buzei like bsis-buzei, " Item No "Insert CR 47607

shkzg like bseg-shkzg, " Dr/Cr Indicator

lifnr like bseg-lifnr, " Vendor Code

matnr like bseg-matnr, " Material No

ebeln like bseg-ebeln, " Purchase Order

ebelp like bseg-ebelp, " PO Item

werks like bseg-werks, " Plant

menge like bseg-menge, " PO Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Amount in Local Currency

wrbtr like bseg-wrbtr, " Amount in Trans.Currency

bpmng like bseg-bpmng, " Order UOM

bprme like bseg-bprme, " Order Base UOM

end of i_bseg.

data: begin of i_bkpf occurs 0,

bukrs like bkpf-bukrs, " Company Code

belnr like bkpf-belnr, " Acc Document

gjahr like bkpf-gjahr, " Fiscal Year

waers like bkpf-waers, " Trans. Currency

awkey like bkpf-awkey, " Object Key

awtyp like bkpf-awtyp, " Reference Procedure

end of i_bkpf.

data: begin of i_mseg occurs 0,

mblnr like mseg-mblnr, " Material Document

mjahr like mseg-mjahr, " Fiscal Year

bwart like mseg-bwart, " Movement Type

matnr like mseg-matnr, " Material No

menge like mseg-menge, " PO Quantity

meins like mseg-meins, " UOM

end of i_mseg.

data: begin of i_mbew occurs 0,

matnr like mbew-matnr, " Material No

werks like mbew-bwkey, " Plant

bklas like mbew-bklas, " Valuation Class

end of i_mbew.

data: begin of i_ekpo occurs 0,

ebeln like ekpo-ebeln, " Purchase Order

ebelp like ekpo-ebelp, " PO Item

ernam like ekko-ernam, " PO Creator

afnam like ekpo-afnam, " PO Requisitioner

matnr like ekpo-matnr, " Material No

txz01 like ekpo-txz01, " Material Text

bednr like ekpo-bednr, " Tracking number OS0335

end of i_ekpo.

data: begin of i_ekkn occurs 0,

ebeln like ekkn-ebeln, " Purchase Order

ebelp like ekkn-ebelp, " PO Item

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

end of i_ekkn.

data: begin of i_lfa1 occurs 0,

lifnr like lfa1-lifnr, " Vendor

name1 like lfa1-name1, " Name

end of i_lfa1.

data: begin of i_user occurs 0,

bname like v_username-bname, " User ID

name1 like v_username-name_text, " User Name

end of i_user.

data: begin of i_final occurs 0,

lifnr like lfa1-lifnr, " Vendor

werks like bseg-werks, " Plant

ekgrp like ekko-ekgrp, " Purch Group

monat like bsis-monat, " Period

matnr like mara-matnr, " Material Number

frbnr like mkpf-frbnr, " Bill of lading no

bednr like ekpo-bednr, " Tracking no

xblnr like mkpf-xblnr, " Ref Doc No

bklas like mbew-bklas, " Val Class

ebeln like bseg-ebeln, " PO

ebelp like bseg-ebelp, " Po Item

crtor like v_username-name_text, " PO Creator

reqnr like v_username-name_text, " PO Requisitioner

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

budat like bsis-budat, " Rec. Date

name1 like lfa1-name1, " Vendor Name

belnr like bsis-belnr, " FI Document

bwart like mseg-bwart, " Movement Type

txz01 like ekpo-txz01, " Material Text

menge like bseg-menge, " Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Local Amount

wrbtr like bseg-wrbtr, " Tran.Amount

waers like bkpf-waers, " Tran.Currency

status type c, " Material Status

end of i_final.

data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory

data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals

data: x_layout type slis_layout_alv, " Structure-layout

x_fldcat like line of i_fldcat, " Structure-field catagory

x_sort like line of i_sort. " Structure-Sort/Subtotals

selection-screen : begin of block b1 with frame title text-000.

parameters:

p_bukrs like t001-bukrs obligatory. " Company Code

select-options:

s_grira for ska1-saknr default '0241101000' obligatory, " Account

s_budat for bkpf-budat, " Posting Date

s_werks for t001w-werks, " Plant

s_ekgrp for ekko-ekgrp, " Purch. Group

s_lifnr for lfa1-lifnr, " Vendor

s_matnr for mara-matnr, " Material Number

s_kostl for csks-kostl, " Cost Center

s_kstar for cska-kstar, " Cost Element

s_ebeln for ekko-ebeln, " Purchase Order

s_monat for bsis-monat. " Period

selection-screen skip.

parameters:

p_incmt as checkbox default 'X',

p_incnm as checkbox default 'X'.

selection-screen skip. " OS0160

parameters: p_disvar like disvariant-variant modif id v1. " OS0160

selection-screen end of block b1.

initialization.

g_repid = sy-repid.

perform layout_init using x_layout.

perform eventtab_build using g_events[].

g_variant-report = g_repid.

g_save = 'A'.

at selection-screen.

perform validate_screen.

at selection-screen on value-request for p_disvar.

perform f_get_var_list.

DATA: BEGIN OF wa_ekko,

ebeln like ekko-ebeln,

ekorg like ekko-ekorg,

ekgrp like ekko-ekgrp,

END OF wa_ekko.

DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

DATA it_bseg LIKE STANDARD TABLE OF i_bseg

WITH HEADER LINE.

SELECT *

FROM bseg

INTO CORRESPONDING FIELDS OF TABLE it_bseg.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'i_bseg'

i_inclname = v_repid

CHANGING

ct_fieldcat = i_fldcat.

v_repid = sy-repid.

<b>I_BSEG[] = IT_BSEG[].</b>

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = i_fldcat

i_callback_user_command = 'USER_COMMAND'

TABLES

t_outtab = it_bseg.

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE i_bseg INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD i_bseg-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.

form validate_screen.

  • Validation of Company Code

clear t001.

if not p_bukrs is initial.

select single bukrs

into t001-bukrs

from t001

where bukrs eq p_bukrs.

if sy-subrc <> 0.

message e899 with 'Enter Valid Company Code'(012).

endif.

endif.

  • Validation of GL Account (GR/IR)

clear ska1.

if not s_grira[] is initial.

select saknr

into ska1-saknr

from ska1

up to 1 rows

where saknr in s_grira.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid GR/IR Account'(013).

endif.

endif.

  • Validation of Vendor Code

clear lfa1.

if not s_lifnr[] is initial.

select single lifnr

into lfa1-lifnr

from lfa1

where lifnr in s_lifnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Vendor'(001).

endif.

endif.

  • Validation of Plant Code

clear t001w.

if not s_werks[] is initial.

select single werks

into t001w-werks

from t001w

where werks in s_werks.

if sy-subrc <> 0.

message e899 with 'Enter Valid Plant'(014).

endif.

endif.

  • Validation of Material Code

clear mara.

if not s_matnr[] is initial.

select single matnr

into mara-matnr

from mara

where matnr in s_matnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Material'(015).

endif.

endif.

  • Validation of Purchase Order

clear ekko.

if not s_ebeln[] is initial.

select single ebeln

into ekko-ebeln

from ekko

where ebeln in s_ebeln.

if sy-subrc <> 0.

message e899 with 'Enter Valid Purchase Order'(016).

endif.

endif.

  • Validation of Cost Center

clear csks.

if not s_kostl[] is initial.

select kostl

into csks-kostl

from csks

up to 1 rows

where kostl in s_kostl.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Center'(017).

endif.

endif.

  • Validation of Cost Element

clear cska.

if not s_kstar[] is initial.

select kstar

into cska-kstar

from cska

up to 1 rows

where kstar in s_kstar.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Element'(018).

endif.

endif.

  • Validate Display variant

if not p_disvar is initial.

g_variant-variant = p_disvar.

if not g_variant-variant is initial.

  • Function module to Check existence of a display variant

call function 'REUSE_ALV_VARIANT_EXISTENCE'

exporting

i_save = c_save

changing

cs_variant = g_variant

exceptions

wrong_input = 1

not_found = 2

program_error = 3

others = 4.

if sy-subrc <> 0.

message e899 with 'Please Enter Valid ALV Variant'.

endif.

endif.

endif.

  • End of insert by OS0160

endform. "validate_screen

&----


*& Form read_data

&----


  • Read the Data from the database Tables

----


form read_data.

  • Start of changes CR 49329

data: begin of i_bseg_lifnr occurs 0,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

lifnr like bseg-lifnr,

end of i_bseg_lifnr.

data: begin of i_bsis_belnr occurs 0,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

end of i_bsis_belnr.

  • End of changes CR 49329

data: l_ekgrp like ekko-ekgrp.

  • Get the Accounting Documents for the GR/IR Account Entered on

  • Selection Screen

clear i_bsis.

refresh i_bsis.

select bukrs " Company Code

hkont " GR IR Account

gjahr " Fiscal Year

belnr " Acc Document

buzei " Item No

budat " Receipt Date(Posting)

monat " Period

into table i_bsis

from bsis

where bukrs = p_bukrs

and hkont in s_grira

and budat in s_budat

and monat in s_monat .

if sy-subrc <> 0.

message i899 with 'No data found'(043).

g_exit = c_x.

stop.

endif.

sort i_bsis by bukrs hkont gjahr belnr buzei.

  • Get the Vendor,PO,Material,Qty details from BSEG Table

if not i_bsis[] is initial.

clear i_bseg.

refresh i_bseg.

select bukrs " Company Code

belnr " Acc Document

  • buzei " Item No "Comment CR 47607

gjahr " Fiscal Year

buzei " Item No "Insert CR 47607

shkzg " Dr/Cr Indicator

lifnr " Vendor Code

matnr " Material No

ebeln " Purchase Order

ebelp " PO Item

werks " Plant

menge " PO Quantity

meins " UOM

dmbtr " Amount in Local Currency

wrbtr " Amount in Trans.Currency

bpmng " Order UOM

bprme " Order Base UOM

into table i_bseg

from bseg

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr

and buzei = i_bsis-buzei

  • and lifnr in s_lifnr

and werks in s_werks

and matnr in s_matnr

and ebeln in s_ebeln.

  • sort i_bseg by bukrs belnr buzei gjahr. "

sort i_bseg by bukrs belnr gjahr buzei. "

check not i_bseg[] is initial.

  • Start of changes

loop at i_bsis.

i_bsis_belnr-bukrs = i_bsis-bukrs.

i_bsis_belnr-belnr = i_bsis-belnr.

i_bsis_belnr-gjahr = i_bsis-gjahr.

append i_bsis_belnr.

clear i_bsis_belnr.

endloop.

sort i_bsis_belnr by bukrs belnr gjahr.

delete adjacent duplicates from i_bsis_belnr.

*-- Getting the lifnr from bseg

select bukrs

belnr

gjahr

lifnr

into table i_bseg_lifnr

from bseg

for all entries in i_bsis_belnr

where bukrs = p_bukrs

and belnr = i_bsis_belnr-belnr

and gjahr = i_bsis_belnr-gjahr

and lifnr in s_lifnr

and KOART = 'K'.

if sy-subrc = 0.

sort i_bseg_lifnr by bukrs belnr gjahr.

*-- Modify the BSEG internal table with lifnr.

loop at i_bseg where lifnr = ' '.

read table i_bseg_lifnr with key bukrs = i_bseg-bukrs

belnr = i_bseg-belnr

gjahr = i_bseg-gjahr

binary search.

if sy-subrc = 0.

i_bseg-lifnr = i_bseg_lifnr-lifnr.

modify i_bseg.

clear i_bseg.

endif.

endloop.

free i_bseg_lifnr.

free i_bsis_belnr.

endif.

delete i_bseg where not lifnr in s_lifnr. " CR53283 OS0160 06.23.2006

  • End of changes CR 49329

  • Get the Material And Description from EKPO Table

if not i_bseg[] is initial.

clear i_ekpo.

refresh i_ekpo.

select b~ebeln " Purchase Order

b~ebelp " PO Item

a~ernam " PO Creator

b~afnam " PO Requisitioner

b~matnr " Material No

b~txz01 " Material Text

b~bednr " Tracking no OS0335

into table i_ekpo

from ekpo as b join ekko as a

on b~ebeln = a~ebeln

for all entries in i_bseg

where b~ebeln = i_bseg-ebeln

and b~ebelp = i_bseg-ebelp.

sort i_ekpo by ebeln ebelp.

  • Get the PO Creator and PO Requisitioner Name

if not i_ekpo[] is initial.

select bname " UserID

name_text " User Name

into table i_user

from v_username

for all entries in i_ekpo

where bname = i_ekpo-ernam or

bname = i_ekpo-afnam.

endif.

sort i_user by bname.

  • Get the Valuation Class from MBEW Table

clear i_mbew.

refresh i_mbew.

select matnr " Material No

bwkey " Plant

bklas " Valuation Class

into table i_mbew

from mbew

for all entries in i_bseg

where matnr = i_bseg-matnr

and bwkey = i_bseg-werks.

sort i_mbew by matnr werks.

  • Get the Cost Center and Cost Element of the PO from EKKN Table

clear i_ekkn.

refresh i_ekkn.

select ebeln " Purchase Order

ebelp " PO Item

kostl " Cost Center

sakto " Cost Element

into table i_ekkn

from ekkn

for all entries in i_bseg

where ebeln = i_bseg-ebeln

and ebelp = i_bseg-ebelp

and kostl in s_kostl

and sakto in s_kstar.

sort i_ekkn by ebeln ebelp.

  • Get the Vendor Name

clear i_lfa1.

refresh i_lfa1.

select lifnr " Vendor

name1 " Name

into table i_lfa1

from lfa1

for all entries in i_bseg

where lifnr = i_bseg-lifnr.

endif.

sort i_lfa1 by lifnr.

  • Select the Trans.Currency from BKPF Table

clear i_bkpf.

refresh i_bkpf.

select bukrs " Company Code

belnr " Acc Document

gjahr " Fiscal Year

waers " Trans. Currency

awkey " Object Key

awtyp " Reference Procedure

into table i_bkpf

from bkpf

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr.

endif.

sort i_bkpf by bukrs belnr gjahr.

  • Get the Quantity and UOM of Material from MSEG Table

if not i_bkpf[] is initial.

clear i_mseg.

refresh i_mseg.

select mblnr " Material Document

mjahr " Fiscal Year

bwart " Movement Type

matnr " Material No

menge " PO Quantity

meins " UOM

into table i_mseg

from mseg

for all entries in i_bkpf

where mblnr = i_bkpf-awkey(10).

endif.

sort i_mseg by mblnr mjahr.

  • Move the data to Final Output Internal Table

loop at i_bsis.

i_final-belnr = i_bsis-belnr. " FI Document

i_final-monat = i_bsis-monat. " Period

i_final-budat = i_bsis-budat. " Rec. Date

  • Read Vendor, Plant, PO Document, Local And Trans.Amounts

  • from BSEG Internal Table

read table i_bseg with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

buzei = i_bsis-buzei

binary search.

if sy-subrc = 0.

i_final-lifnr = i_bseg-lifnr. " Vendor

i_final-werks = i_bseg-werks. " Plant

i_final-ebeln = i_bseg-ebeln. " PO

i_final-ebelp = i_bseg-ebelp. " PO Item

i_final-dmbtr = i_bseg-dmbtr. " Local Amount

i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount

i_final-menge = i_bseg-bpmng. " Order Quantity

i_final-meins = i_bseg-bprme. " Order Base UOM

  • Filter data based upon Purch Org.

select single ekgrp

into l_ekgrp

from ekko

where ebeln = i_bseg-ebeln.

if sy-subrc ne 0.

clear i_final-ekgrp.

else.

if l_ekgrp in s_ekgrp.

i_final-ekgrp = l_ekgrp.

else.

clear i_final.

continue.

endif.

endif.

  • For Credit Indicator(SHKZG = H) amounts should be (-)ve

if i_bseg-shkzg = c_h.

i_final-dmbtr = i_final-dmbtr * -1.

i_final-wrbtr = i_final-wrbtr * -1.

i_final-menge = i_final-menge * -1.

endif.

  • Read the Material and its Description from EKPO Internal Table

read table i_ekpo with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

matnr = i_bseg-matnr

binary search.

if sy-subrc = 0.

i_final-matnr = i_ekpo-matnr. " Material Number

i_final-txz01 = i_ekpo-txz01. " Material Text

i_final-bednr = i_ekpo-bednr. " Tracking no. OS0335

  • Read the PO Creator Name/ID

clear i_user.

read table i_user with key bname = i_ekpo-ernam binary search.

if sy-subrc = 0.

i_final-crtor = i_user-name1. " Po Creator Name

else. " CR 49329

i_final-crtor = i_ekpo-ernam. " CR 49329

endif.

  • Read the PO Requisitioner Name/ID

clear i_user.

read table i_user with key bname = i_ekpo-afnam binary search.

if sy-subrc = 0.

i_final-reqnr = i_user-name1. " Po Requisitioner Name

else. " CR 49329

i_final-reqnr = i_ekpo-afnam. " CR 49329

endif.

  • Populate the Material Status depending on the Input Checkbox

  • On Selection Screen

if not i_ekpo-matnr is initial.

i_final-status = c_x.

endif.

endif.

  • Read the PO related Cost Element and Cost Centers

  • from EKKN Internal Table

read table i_ekkn with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

binary search.

if sy-subrc = 0.

i_final-kostl = i_ekkn-kostl. " Cost Center

i_final-sakto = i_ekkn-sakto. " Cost Element

endif.

  • Read the Valuation Class from MBEW Internal Table

read table i_mbew with key matnr = i_bseg-matnr

werks = i_bseg-werks

binary search.

if sy-subrc = 0.

i_final-bklas = i_mbew-bklas. " Val Class

endif.

  • Read the Vendor Name from LFA1 Internal Table

read table i_lfa1 with key lifnr = i_bseg-lifnr

binary search.

if sy-subrc = 0.

i_final-name1 = i_lfa1-name1. " Vendor Name

endif.

else.

clear i_final.

continue.

endif.

  • Read the Transaction Currency from BKPF Internal Table

read table i_bkpf with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

binary search.

if sy-subrc = 0.

i_final-waers = i_bkpf-waers. " Tran.Currency

  • Read the Movement Type for all Material Related

  • Documents from MSEG Internal Table

if i_bkpf-awtyp = c_mkpf.

read table i_mseg with key mblnr = i_bkpf-awkey(10)

mjahr = i_bkpf-awkey+10(4).

if sy-subrc = 0.

  • Start of changes by OS0335 on 09/16/2004

select single frbnr " Bill of lading No.

xblnr " Reference Doc No OS0160 CR54527

into (i_final-frbnr,

i_final-xblnr)

from mkpf

where mblnr eq i_mseg-mblnr

and mjahr eq i_mseg-mjahr.

  • End of changes by OS0335 on 09/16/2004

i_final-bwart = i_mseg-bwart. " Movement Type

endif.

endif.

endif.

append i_final.

clear i_final.

endloop.

sort i_final by lifnr werks monat matnr.

  • Depending on the check Box Selected display the data

if p_incmt = c_x and p_incnm ne c_x.

delete i_final where matnr eq space.

elseif p_incnm = c_x and p_incmt ne c_x.

delete i_final where matnr ne space.

endif.

endform. "Read Data

----


  • Form : populate_layout_stucture

  • Description : Populating the layout structure

----


form populate_layout_stucture.

clear x_layout .

  • Layout properties

x_layout-zebra = c_x.

x_layout-detail_popup = c_x.

x_layout-detail_initial_lines = c_x.

  • x_layout-colwidth_optimize = c_x. OS0160 - CR54527

endform. " populate_layout_stucture

----


  • Form : build_field_catalog

  • Description : Building the field catalog data

----


form build_field_catalog.

refresh i_fldcat.

clear i_fldcat.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = g_repid

i_internal_tabname = 'I_FINAL'

i_inclname = g_repid

changing

ct_fieldcat = i_fldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

  • Getting the Header text for the coloums

loop at i_fldcat into x_fldcat.

if x_fldcat-fieldname = 'LIFNR'.

x_fldcat-seltext_l = 'Vendor'(003).

x_fldcat-seltext_m = 'Vendor'(003).

x_fldcat-seltext_s = 'Vendor'(003).

x_fldcat-reptext_ddic = 'Vendor'(003).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'NAME1'.

x_fldcat-seltext_l = 'Vendor Name'(002).

x_fldcat-seltext_m = 'Vendor Name'(002).

x_fldcat-seltext_s = 'Vendor Name'(002).

x_fldcat-reptext_ddic = 'Vendor Name'(002).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'WERKS'.

x_fldcat-seltext_l = 'Plant'(010).

x_fldcat-seltext_m = 'Plant'(010).

x_fldcat-seltext_s = 'Plant'(010).

x_fldcat-reptext_ddic = 'Plant'(010).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EKGRP'.

x_fldcat-seltext_l = 'Purch. Group'(108).

x_fldcat-seltext_m = 'Purch. Group'(108).

x_fldcat-seltext_s = 'Purch. Group'(108).

x_fldcat-reptext_ddic = 'Purch. Group'(108).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MONAT'.

x_fldcat-seltext_l = 'Period'(011).

x_fldcat-seltext_m = 'Period'(011).

x_fldcat-seltext_s = 'Period'(011).

x_fldcat-reptext_ddic = 'Period'(011).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MATNR'.

x_fldcat-seltext_l = 'Material'(004).

x_fldcat-seltext_m = 'Material'(004).

x_fldcat-seltext_s = 'Material'(004).

x_fldcat-reptext_ddic = 'Material'(004).

x_fldcat-ddictxt = c_l.

endif.

  • Start of changes

if x_fldcat-fieldname = 'CIMITEM'.

x_fldcat-seltext_l = 'Cimpro Material'(050).

x_fldcat-seltext_m = 'Cimpro Material'(050).

x_fldcat-seltext_s = 'Cimpro Material'(050).

x_fldcat-reptext_ddic = 'Cimpro Material'(050).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'FRBNR'.

x_fldcat-seltext_l = 'Bill of lading'(051).

x_fldcat-seltext_m = 'Bill of lading'(051).

x_fldcat-seltext_s = 'Bill of lading'(051).

x_fldcat-reptext_ddic = 'Bill of lading'(051).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'XBLNR'.

x_fldcat-seltext_l = 'Delivery Note'.

x_fldcat-seltext_m = 'Delivery Note'.

x_fldcat-seltext_s = 'Delivery Note'.

x_fldcat-reptext_ddic = 'Delivery Note'.

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BEDNR'.

x_fldcat-seltext_l = 'Tracking No'(052).

x_fldcat-seltext_m = 'Tracking No'(052).

x_fldcat-seltext_s = 'Tracking No'(052).

x_fldcat-reptext_ddic = 'Tracking No'(052).

x_fldcat-ddictxt = c_l.

endif.

  • End of changes by OS0335 on 09/16/2004

if x_fldcat-fieldname = 'BKLAS'.

x_fldcat-seltext_l = 'Valuation Class'(009).

x_fldcat-seltext_m = 'Valuation Class'(009).

x_fldcat-seltext_s = 'Valuation Class'(009).

x_fldcat-reptext_ddic = 'Valuation Class'(009).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EBELN'.

x_fldcat-seltext_l = 'Purchase Order'(005).

x_fldcat-seltext_m = 'Purchase Order'(005).

x_fldcat-seltext_s = 'Purchase Order'(005).

x_fldcat-reptext_ddic = 'Purchase Order'(005).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EBELP'.

x_fldcat-seltext_l = 'PO Item No'(007).

x_fldcat-seltext_m = 'PO Item No'(007).

x_fldcat-seltext_s = 'PO Item No'(007).

x_fldcat-reptext_ddic = 'PO Item No'(007).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'CRTOR'.

x_fldcat-seltext_l = 'PO Creator'(044).

x_fldcat-seltext_m = 'PO Creator'(044).

x_fldcat-seltext_s = 'PO Creator'(044).

x_fldcat-reptext_ddic = 'PO Creator'(044).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'REQNR'.

x_fldcat-seltext_l = 'PO Requisitioner'(045).

x_fldcat-seltext_m = 'PO Requisitioner'(045).

x_fldcat-seltext_s = 'PO Requisitioner'(045).

x_fldcat-reptext_ddic = 'PO Requisitioner'(045).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'KOSTL'.

x_fldcat-seltext_l = 'Cost Center'(006).

x_fldcat-seltext_m = 'Cost Center'(006).

x_fldcat-seltext_s = 'Cost Center'(006).

x_fldcat-reptext_ddic = 'Cost Center'(006).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BUDAT'.

x_fldcat-seltext_l = 'Receipt Date'(008).

x_fldcat-seltext_m = 'Receipt Date'(008).

x_fldcat-seltext_s = 'Receipt Date'(008).

x_fldcat-reptext_ddic = 'Receipt Date'(008).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BELNR'.

x_fldcat-seltext_l = 'Acc.Document'(100).

x_fldcat-seltext_m = 'Acc.Document'(100).

x_fldcat-seltext_s = 'Acc.Document'(100).

x_fldcat-reptext_ddic = 'Acc.Document'(100).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BWART'.

x_fldcat-seltext_l = 'Movement Type'(101).

x_fldcat-seltext_m = 'Movement Type'(101).

x_fldcat-seltext_s = 'Movement Type'(101).

x_fldcat-reptext_ddic = 'Movement Type'(101).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'TXZ01'.

x_fldcat-seltext_l = 'Material Text'(102).

x_fldcat-seltext_m = 'Material Text'(102).

x_fldcat-seltext_s = 'Material Text'(102).

x_fldcat-reptext_ddic = 'Material Text'(102).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MENGE'.

x_fldcat-seltext_l = 'Quantity'(103).

x_fldcat-seltext_m = 'Quantity'(103).

x_fldcat-seltext_s = 'Quantity'(103).

x_fldcat-reptext_ddic = 'Quantity'(103).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'MEINS'.

x_fldcat-seltext_l = 'UOM'(104).

x_fldcat-seltext_m = 'UOM'(104).

x_fldcat-seltext_s = 'UOM'(104).

x_fldcat-reptext_ddic = 'UOM'(104).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'DMBTR'.

x_fldcat-seltext_l = 'Amount in Local Curr'(105).

x_fldcat-seltext_m = 'Amount in Local Curr'(105).

x_fldcat-seltext_s = 'Amount in Local Curr'(105).

x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WRBTR'.

x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).

x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WAERS'.

x_fldcat-seltext_l = 'Trans.Currency'(107).

x_fldcat-seltext_m = 'Trans.Currency'(107).

x_fldcat-seltext_s = 'Trans.Currency'(107).

x_fldcat-reptext_ddic = 'Trans.Currency'(107).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'STATUS'.

x_fldcat-seltext_l = 'Material Status'(019).

x_fldcat-seltext_m = 'Material Status'(019).

x_fldcat-seltext_s = 'Material Status'(019).

x_fldcat-reptext_ddic = 'Material Status'(019).

x_fldcat-ddictxt = c_l.

endif.

modify i_fldcat from x_fldcat index sy-tabix.

endloop.

endform. " build_field_catalog

----


  • Form : build_sort_totals

  • Description : Building the Criteria for Sort/Subtotals

----


form build_sort_totals.

x_sort-fieldname = 'LIFNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 1.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'WERKS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 2.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'EKGRP'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 3.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MONAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 4.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MATNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 5.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BKLAS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 6.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'EBELN'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 7.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'KOSTL'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 8.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BUDAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 9.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

endform. " build_sort_totals

----


  • Form : comment_build

  • Description : This form is used to display the Report Header(ALV)

----


*

form comment_build using lt_top_of_page type

slis_t_listheader.

data: l_line type slis_listheader,

l_heading1 like rs38m-repti,

l_date(10), l_time(8).

clear l_line.

l_heading1 = 'GR/IR DETAIL REPORT'(021).

g_repid = sy-repid.

write sy-uzeit to l_time.

write sy-datum to l_date.

l_line-typ = c_h.

move l_heading1 to l_line-info.

append l_line to lt_top_of_page.

clear l_line.

l_line-typ = c_s.

concatenate 'System:'(023) sy-sysid

'Date:'(024) l_date

' Time:'(025)

l_time into l_line-info

separated by space.

append l_line to lt_top_of_page.

concatenate 'Report:'(026) g_repid

' User:'(027) sy-uname into

l_line-info

separated by space.

append l_line to lt_top_of_page.

l_line-typ = c_a.

move 'SELECTION CRITERIA:'(028) to l_line-info.

append l_line to lt_top_of_page.

concatenate ' Company Code : '(029)

p_bukrs into l_line-info.

append l_line to lt_top_of_page.

concatenate ' GR/IR Account: '(030) s_grira-low

  • p_grira into l_line-info.

' To: '(031) s_grira-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Posting Date : '(032) s_budat-low

' To: '(031) s_budat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Plant : '(033) s_werks-low

' To: '(031) s_werks-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Purchasing Group : '(020) s_ekgrp-low

' To: '(031) s_ekgrp-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Vendor: '(034) s_lifnr-low

' To: '(031) s_lifnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Material: '(035) s_matnr-low

' To: '(031) s_matnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Center : '(036) s_kostl-low

' To: '(031) s_kostl-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Element: '(037) s_kstar-low

' To: '(031) s_kstar-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Purchase Order: '(038) s_ebeln-low

' To: '(031) s_ebeln-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Period : '(039) s_monat-low

' To: '(031) s_monat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Material Items: '(040)

p_incmt into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Non-Material Items: '(041)

p_incnm into l_line-info.

append l_line to lt_top_of_page.

endform.

----


  • Form : call_list_viewer

  • Description : This form is used to display the grid through ALV

----


form call_list_viewer.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

i_default = c_x

it_sort = i_sort[]

<b>I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'</b>

i_save = g_save

is_variant = g_variant

it_events = g_events[]

importing

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = g_exit_caused_by_user

tables

t_outtab = i_final

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

write: / 'Problem in calling the ALV report'(042).

endif.

endform. " call_list_viewer

<b>FORM USER_COMMAND1

USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE i_final INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD i_final-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.</b>

&----


*& Form GET_DETAILS

&----


  • Populate Cimpro material

----


FORM GET_DETAILS.

loop at i_final where not matnr is initial

and cimitem is initial.

select from_val1

into i_final-cimitem

from znablackbx

up to 1 rows

where obj_id = c_mat_obj

and to_val1 = i_final-matnr.

endselect.

if sy-subrc eq 0.

modify i_final transporting cimitem

where matnr = i_final-matnr.

endif.

endloop.

ENDFORM. " GET_DETAILS

&----


*& Form F_GET_VAR_LIST

&----


  • Get Display Variant list

----


form f_get_var_list.

  • Function module to Display variant selection dialog box

call function 'REUSE_ALV_VARIANT_F4'

exporting

is_variant = g_variant

i_save = g_var_save

importing

e_exit = g_var_exit

es_variant = g_variant1

exceptions

not_found = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

if sy-subrc = 1.

message i899 with 'No Variant exits for the ALV'.

else.

message i899 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

if g_var_exit = space.

p_disvar = g_variant1-variant.

g_variant = g_variant1.

endif.

Thanks,

Naren

24 REPLIES 24
Read only

Former Member
0 Likes
3,974

Hi,

Check the changed code...changes are marked in bold.

form handle_user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'.

case rs_selfield-FIELDNAME.

when 'EBELN'.

<b>read table I_bseg index rs_selfield-tabindex.</b>

if sy-subrc = 0.

set parameter id 'BES' field <b>l_bseg-ebeln</b>.

<b>call transaction 'ME23N' AND SKIP FIRST SCREEN.</b>

endif.

endcase.

endcase.

endform.

Thanks

Naren

Read only

0 Likes
3,974

Thanks Naren.

but when I did u r changes I'm getting the output screen as it is but drill down is not working.

Read only

Former Member
0 Likes
3,974

Hi,

Check this example..This works fine..

TYPE-POOLS: slis.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: BEGIN OF wa_ekko,

ebeln like ekko-ebeln,

ekorg like ekko-ekorg,

ekgrp like ekko-ekgrp,

END OF wa_ekko.

DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

DATA it_ekko LIKE STANDARD TABLE OF wa_ekko WITH HEADER LINE.

SELECT *

FROM ekko

INTO CORRESPONDING FIELDS OF TABLE it_ekko.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'WA_EKKO'

i_inclname = v_repid

CHANGING

ct_fieldcat = gt_fieldcat.

  • Pass the program.

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = gt_fieldcat

i_callback_user_command = 'USER_COMMAND'

TABLES

t_outtab = it_ekko.

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE it_ekko INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD it_ekko-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.

Thanks,

Naren

Read only

0 Likes
3,974

now also the drill down is not working can anyone suggest me where I'm going wrong.

How will the program knows that when we double click on po no in o/p screen it must display po

becoz

when I'm d.clicking no action is done

I'm not getting it I need some help

Read only

Former Member
0 Likes
3,974

Hi,

The sample code that I gave works fine for me..

Paster your program ..so that we can check if you have missed anythig..

Thanks,

Naren

Read only

0 Likes
3,974

Thanks naren

Read only

Former Member
0 Likes
3,974

Hi,

You are using IT_BSEG to display the data..But using I_BSEG to read..

Use internal table IT_BSEG...Changes are marked in bold..

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE <b>IT_BSEG</b> INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD i_bseg-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.

Thanks,

Naren

Read only

0 Likes
3,974

I'm getting error when i kept IT_bseg in place of I_ bseg

it_bseg does not exsts similar fiels i_bseg exists.

Read only

Former Member
0 Likes
3,974

Hi,

Move the it_bseg declaration above the initialization event...to make it as global internal table..

DATA it_bseg LIKE STANDARD TABLE OF i_bseg

WITH HEADER LINE.

INITIALIZATION.

Thanks,

Naren

Read only

0 Likes
3,974

NAREN THANKS FOR U R PATIENCE

But now when i declared it before initialization it is disturbing the orig program.

Read only

Former Member
0 Likes
3,974

Hi,

Move the values from it_bseg to i_bseg before calling the alv fm.

<b>i_bseg[] = it_bseg[].</b>

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = i_fldcat

i_callback_user_command = 'USER_COMMAND'

TABLES

t_outtab = it_bseg.

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE i_bseg INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD i_bseg-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.

Thanks,

Naren

Read only

0 Likes
3,974

there is no change still getting the same error

Read only

Former Member
0 Likes
3,974

Hi,

Don't move the internal table declaration..

Just move the values from the internal table IT_BSEG to I_BSEG.

I_BSEG[] = IT_BSEG[]..

As explained in my last post..

Thanks,

Naren

Read only

0 Likes
3,974

I did same thing I_BSEG[] = IT_BSEG[]

Read only

Former Member
0 Likes
3,974

Hi,

What is the error you are getting??

THanks,

Naren

Read only

0 Likes
3,974

it_bseg does not exsts similar fields i_bseg exists.

Read only

Former Member
0 Likes
3,974

Hi,

First of all ..There are two alv FMs in your program..

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

REUSE_ALV_GRID_DISPLAY

In which one do you want to have the USER_COMMAND..

If you want it for ALV_GRID_DISPLAY..Add the following code marked in bold..

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

<b>I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>

i_default = c_x

Thanks,

Naren

Read only

0 Likes
3,974

my cr is to generate drill down to ebeln and belnr .to an already existing program

the result fun guy wants is if we d.click on po no then he must get the po

The already existing pgm displays the report but document cannot be drilled from the report.

I pasted the whole pgm I'm new to real time work so struggling sorry for troubling u if it is ok I will call u or we can chat in gmail

mhnagini@gmail.com

Read only

Former Member
0 Likes
3,974

Hi,

Please trying passing the parameter I_CALLBACK_USER_COMMAND = 'USER_COMMAND'..

Please do this change..It should work..

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

<b>I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>

Please try this...

You don't have to change any other thing in the program...

Also ignore moving the internal table values as mentioned in my previous post..Just only this change..

Thanks,

Naren

Read only

0 Likes
3,974

I have done but getting same error

it_bseg is unknown similar field i_bseg is ...

I just called reuse alv_ grid_display

do i have to remove Reuse_alv_list _display??

Read only

0 Likes
3,974

When I'm entering the values its fine its working good..

But when I entered ALV VARIANT I'm getting an error

FIELD CATALOG NOT FOUND...

Can anyone help with this why is it coming..

In what cases we gen get this error...

FIELD CATALOG NOT FOUND

Read only

Former Member
0 Likes
3,974

Hi,

Please let me know if it works...

Thanks,

Naren

Read only

Former Member
0 Likes
3,975

Hi,

The changes are marked in bold...I copied the code from your post and made the changes..

Just copy the changes as mentioned..

I have done the user command for both the ALV FMs..

Please go through till the end of the code..

I have added a subroutine USER_COMMAND1..

ables: t001, " Company Codes

t001w, " Plants/Branches

lfa1, " Vendor Master

ska1, " GL Account Master

mara, " Material Master

ekko, " PO Header Data

cska, " Cost Elements

csks, " Cost Centers

bsis, " GL Accounts: Open Items Data

bkpf. " Accounting Doc: Header Data

type-pools : slis.

data: g_repid like sy-repid,

g_exit type c,

g_events type slis_t_event,

g_list_top_of_page type slis_t_listheader,

g_exit_caused_by_caller,

g_exit_caused_by_user type slis_exit_by_user,

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_variant like disvariant,

g_variant1 like disvariant, " To store variant - OS0160

g_var_save type c value 'A', " Save - OS0160

g_var_exit type c, " Exit - OS0160

g_save.

constants : c_x type c value 'X', " Flag

c_c type c value 'C', " Flag

c_l type c value 'L', " Flag

c_a type c value 'A', " Line Type

c_h type c value 'H', " Dr/Cr

c_s type c value 'S', " Line Type

c_mkpf(4) type c value 'MKPF', " Table

c_save type c value 'U', " OS0160

c_mat_obj like znablackbx-obj_id

value 'CIMMATNR'. "Object Id OS0335

data: begin of i_bsis occurs 0,

bukrs like bsis-bukrs, " Company Code

hkont like bsis-hkont, " GR IR Account

gjahr like bsis-gjahr, " Fiscal Year

belnr like bsis-belnr, " Acc Document

buzei like bsis-buzei, " Item No

budat like bsis-budat, " Receipt Date(Posting)

monat like bsis-monat, " Period

end of i_bsis.

data: begin of i_bseg occurs 0,

bukrs like bsis-bukrs, " Company Code

belnr like bsis-belnr, " Acc Document

  • buzei like bsis-buzei, " Item No "Comment CR 47607

gjahr like bsis-gjahr, " Fiscal Year

buzei like bsis-buzei, " Item No "Insert CR 47607

shkzg like bseg-shkzg, " Dr/Cr Indicator

lifnr like bseg-lifnr, " Vendor Code

matnr like bseg-matnr, " Material No

ebeln like bseg-ebeln, " Purchase Order

ebelp like bseg-ebelp, " PO Item

werks like bseg-werks, " Plant

menge like bseg-menge, " PO Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Amount in Local Currency

wrbtr like bseg-wrbtr, " Amount in Trans.Currency

bpmng like bseg-bpmng, " Order UOM

bprme like bseg-bprme, " Order Base UOM

end of i_bseg.

data: begin of i_bkpf occurs 0,

bukrs like bkpf-bukrs, " Company Code

belnr like bkpf-belnr, " Acc Document

gjahr like bkpf-gjahr, " Fiscal Year

waers like bkpf-waers, " Trans. Currency

awkey like bkpf-awkey, " Object Key

awtyp like bkpf-awtyp, " Reference Procedure

end of i_bkpf.

data: begin of i_mseg occurs 0,

mblnr like mseg-mblnr, " Material Document

mjahr like mseg-mjahr, " Fiscal Year

bwart like mseg-bwart, " Movement Type

matnr like mseg-matnr, " Material No

menge like mseg-menge, " PO Quantity

meins like mseg-meins, " UOM

end of i_mseg.

data: begin of i_mbew occurs 0,

matnr like mbew-matnr, " Material No

werks like mbew-bwkey, " Plant

bklas like mbew-bklas, " Valuation Class

end of i_mbew.

data: begin of i_ekpo occurs 0,

ebeln like ekpo-ebeln, " Purchase Order

ebelp like ekpo-ebelp, " PO Item

ernam like ekko-ernam, " PO Creator

afnam like ekpo-afnam, " PO Requisitioner

matnr like ekpo-matnr, " Material No

txz01 like ekpo-txz01, " Material Text

bednr like ekpo-bednr, " Tracking number OS0335

end of i_ekpo.

data: begin of i_ekkn occurs 0,

ebeln like ekkn-ebeln, " Purchase Order

ebelp like ekkn-ebelp, " PO Item

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

end of i_ekkn.

data: begin of i_lfa1 occurs 0,

lifnr like lfa1-lifnr, " Vendor

name1 like lfa1-name1, " Name

end of i_lfa1.

data: begin of i_user occurs 0,

bname like v_username-bname, " User ID

name1 like v_username-name_text, " User Name

end of i_user.

data: begin of i_final occurs 0,

lifnr like lfa1-lifnr, " Vendor

werks like bseg-werks, " Plant

ekgrp like ekko-ekgrp, " Purch Group

monat like bsis-monat, " Period

matnr like mara-matnr, " Material Number

frbnr like mkpf-frbnr, " Bill of lading no

bednr like ekpo-bednr, " Tracking no

xblnr like mkpf-xblnr, " Ref Doc No

bklas like mbew-bklas, " Val Class

ebeln like bseg-ebeln, " PO

ebelp like bseg-ebelp, " Po Item

crtor like v_username-name_text, " PO Creator

reqnr like v_username-name_text, " PO Requisitioner

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

budat like bsis-budat, " Rec. Date

name1 like lfa1-name1, " Vendor Name

belnr like bsis-belnr, " FI Document

bwart like mseg-bwart, " Movement Type

txz01 like ekpo-txz01, " Material Text

menge like bseg-menge, " Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Local Amount

wrbtr like bseg-wrbtr, " Tran.Amount

waers like bkpf-waers, " Tran.Currency

status type c, " Material Status

end of i_final.

data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory

data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals

data: x_layout type slis_layout_alv, " Structure-layout

x_fldcat like line of i_fldcat, " Structure-field catagory

x_sort like line of i_sort. " Structure-Sort/Subtotals

selection-screen : begin of block b1 with frame title text-000.

parameters:

p_bukrs like t001-bukrs obligatory. " Company Code

select-options:

s_grira for ska1-saknr default '0241101000' obligatory, " Account

s_budat for bkpf-budat, " Posting Date

s_werks for t001w-werks, " Plant

s_ekgrp for ekko-ekgrp, " Purch. Group

s_lifnr for lfa1-lifnr, " Vendor

s_matnr for mara-matnr, " Material Number

s_kostl for csks-kostl, " Cost Center

s_kstar for cska-kstar, " Cost Element

s_ebeln for ekko-ebeln, " Purchase Order

s_monat for bsis-monat. " Period

selection-screen skip.

parameters:

p_incmt as checkbox default 'X',

p_incnm as checkbox default 'X'.

selection-screen skip. " OS0160

parameters: p_disvar like disvariant-variant modif id v1. " OS0160

selection-screen end of block b1.

initialization.

g_repid = sy-repid.

perform layout_init using x_layout.

perform eventtab_build using g_events[].

g_variant-report = g_repid.

g_save = 'A'.

at selection-screen.

perform validate_screen.

at selection-screen on value-request for p_disvar.

perform f_get_var_list.

DATA: BEGIN OF wa_ekko,

ebeln like ekko-ebeln,

ekorg like ekko-ekorg,

ekgrp like ekko-ekgrp,

END OF wa_ekko.

DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

DATA it_bseg LIKE STANDARD TABLE OF i_bseg

WITH HEADER LINE.

SELECT *

FROM bseg

INTO CORRESPONDING FIELDS OF TABLE it_bseg.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'i_bseg'

i_inclname = v_repid

CHANGING

ct_fieldcat = i_fldcat.

v_repid = sy-repid.

<b>I_BSEG[] = IT_BSEG[].</b>

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = i_fldcat

i_callback_user_command = 'USER_COMMAND'

TABLES

t_outtab = it_bseg.

FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE i_bseg INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD i_bseg-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.

form validate_screen.

  • Validation of Company Code

clear t001.

if not p_bukrs is initial.

select single bukrs

into t001-bukrs

from t001

where bukrs eq p_bukrs.

if sy-subrc <> 0.

message e899 with 'Enter Valid Company Code'(012).

endif.

endif.

  • Validation of GL Account (GR/IR)

clear ska1.

if not s_grira[] is initial.

select saknr

into ska1-saknr

from ska1

up to 1 rows

where saknr in s_grira.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid GR/IR Account'(013).

endif.

endif.

  • Validation of Vendor Code

clear lfa1.

if not s_lifnr[] is initial.

select single lifnr

into lfa1-lifnr

from lfa1

where lifnr in s_lifnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Vendor'(001).

endif.

endif.

  • Validation of Plant Code

clear t001w.

if not s_werks[] is initial.

select single werks

into t001w-werks

from t001w

where werks in s_werks.

if sy-subrc <> 0.

message e899 with 'Enter Valid Plant'(014).

endif.

endif.

  • Validation of Material Code

clear mara.

if not s_matnr[] is initial.

select single matnr

into mara-matnr

from mara

where matnr in s_matnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Material'(015).

endif.

endif.

  • Validation of Purchase Order

clear ekko.

if not s_ebeln[] is initial.

select single ebeln

into ekko-ebeln

from ekko

where ebeln in s_ebeln.

if sy-subrc <> 0.

message e899 with 'Enter Valid Purchase Order'(016).

endif.

endif.

  • Validation of Cost Center

clear csks.

if not s_kostl[] is initial.

select kostl

into csks-kostl

from csks

up to 1 rows

where kostl in s_kostl.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Center'(017).

endif.

endif.

  • Validation of Cost Element

clear cska.

if not s_kstar[] is initial.

select kstar

into cska-kstar

from cska

up to 1 rows

where kstar in s_kstar.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Element'(018).

endif.

endif.

  • Validate Display variant

if not p_disvar is initial.

g_variant-variant = p_disvar.

if not g_variant-variant is initial.

  • Function module to Check existence of a display variant

call function 'REUSE_ALV_VARIANT_EXISTENCE'

exporting

i_save = c_save

changing

cs_variant = g_variant

exceptions

wrong_input = 1

not_found = 2

program_error = 3

others = 4.

if sy-subrc <> 0.

message e899 with 'Please Enter Valid ALV Variant'.

endif.

endif.

endif.

  • End of insert by OS0160

endform. "validate_screen

&----


*& Form read_data

&----


  • Read the Data from the database Tables

----


form read_data.

  • Start of changes CR 49329

data: begin of i_bseg_lifnr occurs 0,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

lifnr like bseg-lifnr,

end of i_bseg_lifnr.

data: begin of i_bsis_belnr occurs 0,

bukrs like bseg-bukrs,

belnr like bseg-belnr,

gjahr like bseg-gjahr,

end of i_bsis_belnr.

  • End of changes CR 49329

data: l_ekgrp like ekko-ekgrp.

  • Get the Accounting Documents for the GR/IR Account Entered on

  • Selection Screen

clear i_bsis.

refresh i_bsis.

select bukrs " Company Code

hkont " GR IR Account

gjahr " Fiscal Year

belnr " Acc Document

buzei " Item No

budat " Receipt Date(Posting)

monat " Period

into table i_bsis

from bsis

where bukrs = p_bukrs

and hkont in s_grira

and budat in s_budat

and monat in s_monat .

if sy-subrc <> 0.

message i899 with 'No data found'(043).

g_exit = c_x.

stop.

endif.

sort i_bsis by bukrs hkont gjahr belnr buzei.

  • Get the Vendor,PO,Material,Qty details from BSEG Table

if not i_bsis[] is initial.

clear i_bseg.

refresh i_bseg.

select bukrs " Company Code

belnr " Acc Document

  • buzei " Item No "Comment CR 47607

gjahr " Fiscal Year

buzei " Item No "Insert CR 47607

shkzg " Dr/Cr Indicator

lifnr " Vendor Code

matnr " Material No

ebeln " Purchase Order

ebelp " PO Item

werks " Plant

menge " PO Quantity

meins " UOM

dmbtr " Amount in Local Currency

wrbtr " Amount in Trans.Currency

bpmng " Order UOM

bprme " Order Base UOM

into table i_bseg

from bseg

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr

and buzei = i_bsis-buzei

  • and lifnr in s_lifnr

and werks in s_werks

and matnr in s_matnr

and ebeln in s_ebeln.

  • sort i_bseg by bukrs belnr buzei gjahr. "

sort i_bseg by bukrs belnr gjahr buzei. "

check not i_bseg[] is initial.

  • Start of changes

loop at i_bsis.

i_bsis_belnr-bukrs = i_bsis-bukrs.

i_bsis_belnr-belnr = i_bsis-belnr.

i_bsis_belnr-gjahr = i_bsis-gjahr.

append i_bsis_belnr.

clear i_bsis_belnr.

endloop.

sort i_bsis_belnr by bukrs belnr gjahr.

delete adjacent duplicates from i_bsis_belnr.

*-- Getting the lifnr from bseg

select bukrs

belnr

gjahr

lifnr

into table i_bseg_lifnr

from bseg

for all entries in i_bsis_belnr

where bukrs = p_bukrs

and belnr = i_bsis_belnr-belnr

and gjahr = i_bsis_belnr-gjahr

and lifnr in s_lifnr

and KOART = 'K'.

if sy-subrc = 0.

sort i_bseg_lifnr by bukrs belnr gjahr.

*-- Modify the BSEG internal table with lifnr.

loop at i_bseg where lifnr = ' '.

read table i_bseg_lifnr with key bukrs = i_bseg-bukrs

belnr = i_bseg-belnr

gjahr = i_bseg-gjahr

binary search.

if sy-subrc = 0.

i_bseg-lifnr = i_bseg_lifnr-lifnr.

modify i_bseg.

clear i_bseg.

endif.

endloop.

free i_bseg_lifnr.

free i_bsis_belnr.

endif.

delete i_bseg where not lifnr in s_lifnr. " CR53283 OS0160 06.23.2006

  • End of changes CR 49329

  • Get the Material And Description from EKPO Table

if not i_bseg[] is initial.

clear i_ekpo.

refresh i_ekpo.

select b~ebeln " Purchase Order

b~ebelp " PO Item

a~ernam " PO Creator

b~afnam " PO Requisitioner

b~matnr " Material No

b~txz01 " Material Text

b~bednr " Tracking no OS0335

into table i_ekpo

from ekpo as b join ekko as a

on b~ebeln = a~ebeln

for all entries in i_bseg

where b~ebeln = i_bseg-ebeln

and b~ebelp = i_bseg-ebelp.

sort i_ekpo by ebeln ebelp.

  • Get the PO Creator and PO Requisitioner Name

if not i_ekpo[] is initial.

select bname " UserID

name_text " User Name

into table i_user

from v_username

for all entries in i_ekpo

where bname = i_ekpo-ernam or

bname = i_ekpo-afnam.

endif.

sort i_user by bname.

  • Get the Valuation Class from MBEW Table

clear i_mbew.

refresh i_mbew.

select matnr " Material No

bwkey " Plant

bklas " Valuation Class

into table i_mbew

from mbew

for all entries in i_bseg

where matnr = i_bseg-matnr

and bwkey = i_bseg-werks.

sort i_mbew by matnr werks.

  • Get the Cost Center and Cost Element of the PO from EKKN Table

clear i_ekkn.

refresh i_ekkn.

select ebeln " Purchase Order

ebelp " PO Item

kostl " Cost Center

sakto " Cost Element

into table i_ekkn

from ekkn

for all entries in i_bseg

where ebeln = i_bseg-ebeln

and ebelp = i_bseg-ebelp

and kostl in s_kostl

and sakto in s_kstar.

sort i_ekkn by ebeln ebelp.

  • Get the Vendor Name

clear i_lfa1.

refresh i_lfa1.

select lifnr " Vendor

name1 " Name

into table i_lfa1

from lfa1

for all entries in i_bseg

where lifnr = i_bseg-lifnr.

endif.

sort i_lfa1 by lifnr.

  • Select the Trans.Currency from BKPF Table

clear i_bkpf.

refresh i_bkpf.

select bukrs " Company Code

belnr " Acc Document

gjahr " Fiscal Year

waers " Trans. Currency

awkey " Object Key

awtyp " Reference Procedure

into table i_bkpf

from bkpf

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr.

endif.

sort i_bkpf by bukrs belnr gjahr.

  • Get the Quantity and UOM of Material from MSEG Table

if not i_bkpf[] is initial.

clear i_mseg.

refresh i_mseg.

select mblnr " Material Document

mjahr " Fiscal Year

bwart " Movement Type

matnr " Material No

menge " PO Quantity

meins " UOM

into table i_mseg

from mseg

for all entries in i_bkpf

where mblnr = i_bkpf-awkey(10).

endif.

sort i_mseg by mblnr mjahr.

  • Move the data to Final Output Internal Table

loop at i_bsis.

i_final-belnr = i_bsis-belnr. " FI Document

i_final-monat = i_bsis-monat. " Period

i_final-budat = i_bsis-budat. " Rec. Date

  • Read Vendor, Plant, PO Document, Local And Trans.Amounts

  • from BSEG Internal Table

read table i_bseg with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

buzei = i_bsis-buzei

binary search.

if sy-subrc = 0.

i_final-lifnr = i_bseg-lifnr. " Vendor

i_final-werks = i_bseg-werks. " Plant

i_final-ebeln = i_bseg-ebeln. " PO

i_final-ebelp = i_bseg-ebelp. " PO Item

i_final-dmbtr = i_bseg-dmbtr. " Local Amount

i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount

i_final-menge = i_bseg-bpmng. " Order Quantity

i_final-meins = i_bseg-bprme. " Order Base UOM

  • Filter data based upon Purch Org.

select single ekgrp

into l_ekgrp

from ekko

where ebeln = i_bseg-ebeln.

if sy-subrc ne 0.

clear i_final-ekgrp.

else.

if l_ekgrp in s_ekgrp.

i_final-ekgrp = l_ekgrp.

else.

clear i_final.

continue.

endif.

endif.

  • For Credit Indicator(SHKZG = H) amounts should be (-)ve

if i_bseg-shkzg = c_h.

i_final-dmbtr = i_final-dmbtr * -1.

i_final-wrbtr = i_final-wrbtr * -1.

i_final-menge = i_final-menge * -1.

endif.

  • Read the Material and its Description from EKPO Internal Table

read table i_ekpo with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

matnr = i_bseg-matnr

binary search.

if sy-subrc = 0.

i_final-matnr = i_ekpo-matnr. " Material Number

i_final-txz01 = i_ekpo-txz01. " Material Text

i_final-bednr = i_ekpo-bednr. " Tracking no. OS0335

  • Read the PO Creator Name/ID

clear i_user.

read table i_user with key bname = i_ekpo-ernam binary search.

if sy-subrc = 0.

i_final-crtor = i_user-name1. " Po Creator Name

else. " CR 49329

i_final-crtor = i_ekpo-ernam. " CR 49329

endif.

  • Read the PO Requisitioner Name/ID

clear i_user.

read table i_user with key bname = i_ekpo-afnam binary search.

if sy-subrc = 0.

i_final-reqnr = i_user-name1. " Po Requisitioner Name

else. " CR 49329

i_final-reqnr = i_ekpo-afnam. " CR 49329

endif.

  • Populate the Material Status depending on the Input Checkbox

  • On Selection Screen

if not i_ekpo-matnr is initial.

i_final-status = c_x.

endif.

endif.

  • Read the PO related Cost Element and Cost Centers

  • from EKKN Internal Table

read table i_ekkn with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

binary search.

if sy-subrc = 0.

i_final-kostl = i_ekkn-kostl. " Cost Center

i_final-sakto = i_ekkn-sakto. " Cost Element

endif.

  • Read the Valuation Class from MBEW Internal Table

read table i_mbew with key matnr = i_bseg-matnr

werks = i_bseg-werks

binary search.

if sy-subrc = 0.

i_final-bklas = i_mbew-bklas. " Val Class

endif.

  • Read the Vendor Name from LFA1 Internal Table

read table i_lfa1 with key lifnr = i_bseg-lifnr

binary search.

if sy-subrc = 0.

i_final-name1 = i_lfa1-name1. " Vendor Name

endif.

else.

clear i_final.

continue.

endif.

  • Read the Transaction Currency from BKPF Internal Table

read table i_bkpf with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

binary search.

if sy-subrc = 0.

i_final-waers = i_bkpf-waers. " Tran.Currency

  • Read the Movement Type for all Material Related

  • Documents from MSEG Internal Table

if i_bkpf-awtyp = c_mkpf.

read table i_mseg with key mblnr = i_bkpf-awkey(10)

mjahr = i_bkpf-awkey+10(4).

if sy-subrc = 0.

  • Start of changes by OS0335 on 09/16/2004

select single frbnr " Bill of lading No.

xblnr " Reference Doc No OS0160 CR54527

into (i_final-frbnr,

i_final-xblnr)

from mkpf

where mblnr eq i_mseg-mblnr

and mjahr eq i_mseg-mjahr.

  • End of changes by OS0335 on 09/16/2004

i_final-bwart = i_mseg-bwart. " Movement Type

endif.

endif.

endif.

append i_final.

clear i_final.

endloop.

sort i_final by lifnr werks monat matnr.

  • Depending on the check Box Selected display the data

if p_incmt = c_x and p_incnm ne c_x.

delete i_final where matnr eq space.

elseif p_incnm = c_x and p_incmt ne c_x.

delete i_final where matnr ne space.

endif.

endform. "Read Data

----


  • Form : populate_layout_stucture

  • Description : Populating the layout structure

----


form populate_layout_stucture.

clear x_layout .

  • Layout properties

x_layout-zebra = c_x.

x_layout-detail_popup = c_x.

x_layout-detail_initial_lines = c_x.

  • x_layout-colwidth_optimize = c_x. OS0160 - CR54527

endform. " populate_layout_stucture

----


  • Form : build_field_catalog

  • Description : Building the field catalog data

----


form build_field_catalog.

refresh i_fldcat.

clear i_fldcat.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = g_repid

i_internal_tabname = 'I_FINAL'

i_inclname = g_repid

changing

ct_fieldcat = i_fldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

  • Getting the Header text for the coloums

loop at i_fldcat into x_fldcat.

if x_fldcat-fieldname = 'LIFNR'.

x_fldcat-seltext_l = 'Vendor'(003).

x_fldcat-seltext_m = 'Vendor'(003).

x_fldcat-seltext_s = 'Vendor'(003).

x_fldcat-reptext_ddic = 'Vendor'(003).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'NAME1'.

x_fldcat-seltext_l = 'Vendor Name'(002).

x_fldcat-seltext_m = 'Vendor Name'(002).

x_fldcat-seltext_s = 'Vendor Name'(002).

x_fldcat-reptext_ddic = 'Vendor Name'(002).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'WERKS'.

x_fldcat-seltext_l = 'Plant'(010).

x_fldcat-seltext_m = 'Plant'(010).

x_fldcat-seltext_s = 'Plant'(010).

x_fldcat-reptext_ddic = 'Plant'(010).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EKGRP'.

x_fldcat-seltext_l = 'Purch. Group'(108).

x_fldcat-seltext_m = 'Purch. Group'(108).

x_fldcat-seltext_s = 'Purch. Group'(108).

x_fldcat-reptext_ddic = 'Purch. Group'(108).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MONAT'.

x_fldcat-seltext_l = 'Period'(011).

x_fldcat-seltext_m = 'Period'(011).

x_fldcat-seltext_s = 'Period'(011).

x_fldcat-reptext_ddic = 'Period'(011).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MATNR'.

x_fldcat-seltext_l = 'Material'(004).

x_fldcat-seltext_m = 'Material'(004).

x_fldcat-seltext_s = 'Material'(004).

x_fldcat-reptext_ddic = 'Material'(004).

x_fldcat-ddictxt = c_l.

endif.

  • Start of changes

if x_fldcat-fieldname = 'CIMITEM'.

x_fldcat-seltext_l = 'Cimpro Material'(050).

x_fldcat-seltext_m = 'Cimpro Material'(050).

x_fldcat-seltext_s = 'Cimpro Material'(050).

x_fldcat-reptext_ddic = 'Cimpro Material'(050).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'FRBNR'.

x_fldcat-seltext_l = 'Bill of lading'(051).

x_fldcat-seltext_m = 'Bill of lading'(051).

x_fldcat-seltext_s = 'Bill of lading'(051).

x_fldcat-reptext_ddic = 'Bill of lading'(051).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'XBLNR'.

x_fldcat-seltext_l = 'Delivery Note'.

x_fldcat-seltext_m = 'Delivery Note'.

x_fldcat-seltext_s = 'Delivery Note'.

x_fldcat-reptext_ddic = 'Delivery Note'.

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BEDNR'.

x_fldcat-seltext_l = 'Tracking No'(052).

x_fldcat-seltext_m = 'Tracking No'(052).

x_fldcat-seltext_s = 'Tracking No'(052).

x_fldcat-reptext_ddic = 'Tracking No'(052).

x_fldcat-ddictxt = c_l.

endif.

  • End of changes by OS0335 on 09/16/2004

if x_fldcat-fieldname = 'BKLAS'.

x_fldcat-seltext_l = 'Valuation Class'(009).

x_fldcat-seltext_m = 'Valuation Class'(009).

x_fldcat-seltext_s = 'Valuation Class'(009).

x_fldcat-reptext_ddic = 'Valuation Class'(009).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EBELN'.

x_fldcat-seltext_l = 'Purchase Order'(005).

x_fldcat-seltext_m = 'Purchase Order'(005).

x_fldcat-seltext_s = 'Purchase Order'(005).

x_fldcat-reptext_ddic = 'Purchase Order'(005).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EBELP'.

x_fldcat-seltext_l = 'PO Item No'(007).

x_fldcat-seltext_m = 'PO Item No'(007).

x_fldcat-seltext_s = 'PO Item No'(007).

x_fldcat-reptext_ddic = 'PO Item No'(007).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'CRTOR'.

x_fldcat-seltext_l = 'PO Creator'(044).

x_fldcat-seltext_m = 'PO Creator'(044).

x_fldcat-seltext_s = 'PO Creator'(044).

x_fldcat-reptext_ddic = 'PO Creator'(044).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'REQNR'.

x_fldcat-seltext_l = 'PO Requisitioner'(045).

x_fldcat-seltext_m = 'PO Requisitioner'(045).

x_fldcat-seltext_s = 'PO Requisitioner'(045).

x_fldcat-reptext_ddic = 'PO Requisitioner'(045).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'KOSTL'.

x_fldcat-seltext_l = 'Cost Center'(006).

x_fldcat-seltext_m = 'Cost Center'(006).

x_fldcat-seltext_s = 'Cost Center'(006).

x_fldcat-reptext_ddic = 'Cost Center'(006).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BUDAT'.

x_fldcat-seltext_l = 'Receipt Date'(008).

x_fldcat-seltext_m = 'Receipt Date'(008).

x_fldcat-seltext_s = 'Receipt Date'(008).

x_fldcat-reptext_ddic = 'Receipt Date'(008).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BELNR'.

x_fldcat-seltext_l = 'Acc.Document'(100).

x_fldcat-seltext_m = 'Acc.Document'(100).

x_fldcat-seltext_s = 'Acc.Document'(100).

x_fldcat-reptext_ddic = 'Acc.Document'(100).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BWART'.

x_fldcat-seltext_l = 'Movement Type'(101).

x_fldcat-seltext_m = 'Movement Type'(101).

x_fldcat-seltext_s = 'Movement Type'(101).

x_fldcat-reptext_ddic = 'Movement Type'(101).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'TXZ01'.

x_fldcat-seltext_l = 'Material Text'(102).

x_fldcat-seltext_m = 'Material Text'(102).

x_fldcat-seltext_s = 'Material Text'(102).

x_fldcat-reptext_ddic = 'Material Text'(102).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MENGE'.

x_fldcat-seltext_l = 'Quantity'(103).

x_fldcat-seltext_m = 'Quantity'(103).

x_fldcat-seltext_s = 'Quantity'(103).

x_fldcat-reptext_ddic = 'Quantity'(103).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'MEINS'.

x_fldcat-seltext_l = 'UOM'(104).

x_fldcat-seltext_m = 'UOM'(104).

x_fldcat-seltext_s = 'UOM'(104).

x_fldcat-reptext_ddic = 'UOM'(104).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'DMBTR'.

x_fldcat-seltext_l = 'Amount in Local Curr'(105).

x_fldcat-seltext_m = 'Amount in Local Curr'(105).

x_fldcat-seltext_s = 'Amount in Local Curr'(105).

x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WRBTR'.

x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).

x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WAERS'.

x_fldcat-seltext_l = 'Trans.Currency'(107).

x_fldcat-seltext_m = 'Trans.Currency'(107).

x_fldcat-seltext_s = 'Trans.Currency'(107).

x_fldcat-reptext_ddic = 'Trans.Currency'(107).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'STATUS'.

x_fldcat-seltext_l = 'Material Status'(019).

x_fldcat-seltext_m = 'Material Status'(019).

x_fldcat-seltext_s = 'Material Status'(019).

x_fldcat-reptext_ddic = 'Material Status'(019).

x_fldcat-ddictxt = c_l.

endif.

modify i_fldcat from x_fldcat index sy-tabix.

endloop.

endform. " build_field_catalog

----


  • Form : build_sort_totals

  • Description : Building the Criteria for Sort/Subtotals

----


form build_sort_totals.

x_sort-fieldname = 'LIFNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 1.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'WERKS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 2.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'EKGRP'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 3.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MONAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 4.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MATNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 5.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BKLAS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 6.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'EBELN'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 7.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'KOSTL'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 8.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BUDAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 9.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

endform. " build_sort_totals

----


  • Form : comment_build

  • Description : This form is used to display the Report Header(ALV)

----


*

form comment_build using lt_top_of_page type

slis_t_listheader.

data: l_line type slis_listheader,

l_heading1 like rs38m-repti,

l_date(10), l_time(8).

clear l_line.

l_heading1 = 'GR/IR DETAIL REPORT'(021).

g_repid = sy-repid.

write sy-uzeit to l_time.

write sy-datum to l_date.

l_line-typ = c_h.

move l_heading1 to l_line-info.

append l_line to lt_top_of_page.

clear l_line.

l_line-typ = c_s.

concatenate 'System:'(023) sy-sysid

'Date:'(024) l_date

' Time:'(025)

l_time into l_line-info

separated by space.

append l_line to lt_top_of_page.

concatenate 'Report:'(026) g_repid

' User:'(027) sy-uname into

l_line-info

separated by space.

append l_line to lt_top_of_page.

l_line-typ = c_a.

move 'SELECTION CRITERIA:'(028) to l_line-info.

append l_line to lt_top_of_page.

concatenate ' Company Code : '(029)

p_bukrs into l_line-info.

append l_line to lt_top_of_page.

concatenate ' GR/IR Account: '(030) s_grira-low

  • p_grira into l_line-info.

' To: '(031) s_grira-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Posting Date : '(032) s_budat-low

' To: '(031) s_budat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Plant : '(033) s_werks-low

' To: '(031) s_werks-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Purchasing Group : '(020) s_ekgrp-low

' To: '(031) s_ekgrp-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Vendor: '(034) s_lifnr-low

' To: '(031) s_lifnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Material: '(035) s_matnr-low

' To: '(031) s_matnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Center : '(036) s_kostl-low

' To: '(031) s_kostl-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Element: '(037) s_kstar-low

' To: '(031) s_kstar-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Purchase Order: '(038) s_ebeln-low

' To: '(031) s_ebeln-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Period : '(039) s_monat-low

' To: '(031) s_monat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Material Items: '(040)

p_incmt into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Non-Material Items: '(041)

p_incnm into l_line-info.

append l_line to lt_top_of_page.

endform.

----


  • Form : call_list_viewer

  • Description : This form is used to display the grid through ALV

----


form call_list_viewer.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

i_default = c_x

it_sort = i_sort[]

<b>I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'</b>

i_save = g_save

is_variant = g_variant

it_events = g_events[]

importing

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = g_exit_caused_by_user

tables

t_outtab = i_final

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

write: / 'Problem in calling the ALV report'(042).

endif.

endform. " call_list_viewer

<b>FORM USER_COMMAND1

USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

IF ucomm = '&IC1' and selfield-fieldname = 'EBELN'.

READ TABLE i_final INDEX selfield-tabindex.

IF sy-subrc = 0.

SET PARAMETER ID 'BES' FIELD i_final-ebeln.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDIF.

ENDFORM.</b>

&----


*& Form GET_DETAILS

&----


  • Populate Cimpro material

----


FORM GET_DETAILS.

loop at i_final where not matnr is initial

and cimitem is initial.

select from_val1

into i_final-cimitem

from znablackbx

up to 1 rows

where obj_id = c_mat_obj

and to_val1 = i_final-matnr.

endselect.

if sy-subrc eq 0.

modify i_final transporting cimitem

where matnr = i_final-matnr.

endif.

endloop.

ENDFORM. " GET_DETAILS

&----


*& Form F_GET_VAR_LIST

&----


  • Get Display Variant list

----


form f_get_var_list.

  • Function module to Display variant selection dialog box

call function 'REUSE_ALV_VARIANT_F4'

exporting

is_variant = g_variant

i_save = g_var_save

importing

e_exit = g_var_exit

es_variant = g_variant1

exceptions

not_found = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

if sy-subrc = 1.

message i899 with 'No Variant exits for the ALV'.

else.

message i899 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

if g_var_exit = space.

p_disvar = g_variant1-variant.

g_variant = g_variant1.

endif.

Thanks,

Naren

Read only

Former Member
0 Likes
3,974

got an error