Application Development 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: 

function module

Former Member
0 Kudos

hi to all experts,

what is the work functoinlity of this function module.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

please explain me with exmaple .

thanks in advance and reward also.

regard : deep.

2 REPLIES 2

sailaja_vadlamudi
Contributor
0 Kudos

HI

REUSE_ALV_VARIANT_DEFAULT_GET:

Purpose: Provides the default variant for the list specified in the structure

parameter CS_VARIANT of a program.

Function Call:

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = 'A'

CHANGING

CS_VARIANT = I_VARIANT

Parameters

I_SAVE :

Description :

Controls the storage mode

Prerequisite:

The IS_VARIANT parameter has the appropriate value.

Value range

' ' = display variants cannot be saved

Defined display variants (e.g. delivered display variants) can be

selected for presentation independently of this flag.

Changes cannot be saved.

'X' = standard save

Display variants can be saved as standard display variants.

User-specific saving is not possible.

'U' = only user-specific saving

The user can only save display variants user-specifically

'A' = standard and user-specific saving

The user can save a display variant user-specifically and

as standard display variant. The user chooses in the display variant

save popup.

CS_VARIANT:

Internal table containing the program name (and the default variant---optional )

Example...

CONSTANTS: c_yes(1) TYPE c VALUE 'X'.

...

DATA: e_variant TYPE disvariant.

...

PARAMETERS: p_vari LIKE disvariant-variant.

...

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

CLEAR e_variant.

e_variant-report = sy-cprog.

e_variant-username = sy-uname.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = c_yes

CHANGING

cs_variant = e_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_vari = e_variant-variant.

ENDIF.

PERFORM f4_for_variant.

...

FORM f4_for_variant.

*

DATA: l_exit(1) TYPE c.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = e_variant

i_tabname_header = 'T_LISTADO'

  • i_tabname_item = ' '

  • IT_DEFAULT_FIELDCAT =

i_save = 'A'

IMPORTING

e_exit = l_exit

es_variant = e_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 2.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

IF l_exit = space.

p_vari = e_variant-variant.

ENDIF.

ENDIF.

*

ENDFORM. " f4_for_variant

This allows you to enter a display variant BEFORE running your ALV report. Then, your call to the ALV should look a little bit like this:

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

...

is_variant = e_variant

Sail

Former Member
0 Kudos

HI

<b>'REUSE_ALV_VARIANT_DEFAULT_GET'</b>

Read default display variant (description only, w/o field catalog)

<b>Functionality</b>

Provides the default variant for the list specified in the structure parameter CS_VARIANT of a program.

<b>Parameters</b>

I_SAVE

CS_VARIANT

<b>Exceptions</b>

WRONG_INPUT

NOT_FOUND

PROGRAM_ERROR

<b>Function Group</b>

SALV

&----


*& Report ZVE_SIMPLE1

*&

&----


*&

*&

&----


REPORT ZVE_SIMPLE1.

**A Simple ABAP ALV LIST VIEWER Example

**This ALV program have all the basic report requirements such as page heading,

  • page no, sub-total and a grand total.

      • This is a basic ALV with the followings:-

      • - Page Heading

      • - Page No

      • - Sub-Total

      • - Grand Total

**REPORT ZALV.

*TYPE-POOLS: SLIS.

*DATA: G_REPID LIKE SY-REPID,

*GS_PRINT TYPE SLIS_PRINT_ALV,

*GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

*GT_EVENTS TYPE SLIS_T_EVENT,

*GT_SORT TYPE SLIS_T_SORTINFO_ALV,

*GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

*GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

*FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,

*COL_POS TYPE I.

*DATA: BEGIN OF ITAB,

  • FIELD1(5) TYPE C,

  • FIELD2(5) TYPE C,

  • FIELD3(5) TYPE P DECIMALS 2,

*END OF ITAB.

*DATA: BEGIN OF ITAB1 OCCURS 0.

  • INCLUDE STRUCTURE ITAB.

*DATA: END OF ITAB1.

*DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.

  • INCLUDE STRUCTURE ITAB.

*DATA: END OF ITAB_FIELDCAT.

    • Print Parameters

*PARAMETERS:

  • P_PRINT AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE

  • P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO

  • P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE

  • P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE

  • P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO

  • P_RESERV TYPE I. "NO OF FOOTER LINE

*INITIALIZATION.

*G_REPID = SY-REPID.

*PERFORM PRINT_BUILD USING GS_PRINT. "Print PARAMETERS

*START-OF-SELECTION.

    • TEST DATA

*MOVE 'TEST1' TO ITAB1-FIELD1.

*MOVE 'TEST1' TO ITAB1-FIELD2.

*MOVE '10.00' TO ITAB1-FIELD3.

*APPEND ITAB1.

*MOVE 'TEST2' TO ITAB1-FIELD1.

*MOVE 'TEST2' TO ITAB1-FIELD2.

*MOVE '20.00' TO ITAB1-FIELD3.

*APPEND ITAB1.

*DO 50 TIMES.

  • APPEND ITAB1.

*ENDDO.

*END-OF-SELECTION.

*PERFORM BUILD.

*PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.

*PERFORM COMMENT_BUILD CHANGING GT_LIST_TOP_OF_PAGE.

*PERFORM CALL_ALV.

*FORM BUILD.

    • DATA FIELD CATALOG

    • Explain Field Description to ALV

*DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.

*CLEAR FIELDCAT_IN.

*FIELDCAT_LN-FIELDNAME = 'FIELD1'.

*FIELDCAT_LN-TABNAME = 'ITAB1'.

**FIELDCAT_LN-NO_OUT = 'X'. "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT

*FIELDCAT_LN-KEY = ' '. "SUBTOTAL KEY

*FIELDCAT_LN-NO_OUT = ' '.

*FIELDCAT_LN-SELTEXT_L = 'HEAD1'.

*APPEND FIELDCAT_LN TO GT_FIELDCAT.

*CLEAR FIELDCAT_IN.

*FIELDCAT_LN-FIELDNAME = 'FIELD2'.

*FIELDCAT_LN-TABNAME = 'ITAB1'.

*FIELDCAT_LN-NO_OUT = 'X'.

*FIELDCAT_LN-SELTEXT_L = 'HEAD2'.

*APPEND FIELDCAT_LN TO GT_FIELDCAT.

*CLEAR FIELDCAT_IN.

*FIELDCAT_LN-FIELDNAME = 'FIELD3'.

*FIELDCAT_LN-TABNAME = 'ITAB1'.

*FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY

*FIELDCAT_LN-REF_TABNAME = 'MSEG'. "<- REF TABLE IN THE DICTIONNARY

*FIELDCAT_LN-NO_OUT = ' '.

*FIELDCAT_LN-DO_SUM = 'X'. "SUM UPON DISPLAY

*APPEND FIELDCAT_LN TO GT_FIELDCAT.

    • DATA SORTING AND SUBTOTAL

*DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.

*CLEAR GS_SORT.

*GS_SORT-FIELDNAME = 'FIELD1'.

*GS_SORT-SPOS = 1.

*GS_SORT-UP = 'X'.

*GS_SORT-SUBTOT = 'X'.

*APPEND GS_SORT TO GT_SORT.

*CLEAR GS_SORT.

*GS_SORT-FIELDNAME = 'FIELD2'.

*GS_SORT-SPOS = 2.

*GS_SORT-UP = 'X'.

**GS_SORT-SUBTOT = 'X'.

*APPEND GS_SORT TO GT_SORT.

*ENDFORM.

*FORM CALL_ALV.

    • ABAP List Viewer

*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

*EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

*I_CALLBACK_PROGRAM = G_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

*I_STRUCTURE_NAME = 'ITAB1'

*IS_LAYOUT = GS_LAYOUT

*IT_FIELDCAT = GT_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

  • IT_SORT = GT_SORT[]

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

  • IT_EVENTS = GT_EVENTS[]

    • IT_EVENT_EXIT =

  • IS_PRINT = GS_PRINT

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

*TABLES

*T_OUTTAB = ITAB1

*EXCEPTIONS

*PROGRAM_ERROR = 1

*OTHERS = 2.

*ENDFORM.

    • HEADER FORM

*FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.

*CONSTANTS:

*GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

**GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.

  • DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

  • CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

  • IMPORTING

  • ET_EVENTS = LT_EVENTS.

  • READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

  • INTO LS_EVENT.

  • IF SY-SUBRC = 0.

  • MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

  • APPEND LS_EVENT TO LT_EVENTS.

  • ENDIF.

    • define END_OF_PAGE event

    • READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

    • INTO LS_EVENT.

    • IF SY-SUBRC = 0.

    • MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.

    • APPEND LS_EVENT TO LT_EVENTS.

    • ENDIF.

*ENDFORM.

*FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

  • DATA: GS_LINE TYPE SLIS_LISTHEADER.

  • CLEAR GS_LINE.

  • GS_LINE-TYP = 'H'.

  • GS_LINE-INFO = 'HEADER 1'.

  • APPEND GS_LINE TO GT_TOP_OF_PAGE.

  • CLEAR GS_LINE.

  • GS_LINE-TYP = 'S'.

  • GS_LINE-KEY = 'STATUS 1'.

  • GS_LINE-INFO = 'INFO 1'.

  • APPEND GS_LINE TO GT_TOP_OF_PAGE.

  • GS_LINE-KEY = 'STATUS 2'.

  • GS_LINE-INFO = 'INFO 2'.

  • APPEND GS_LINE TO GT_TOP_OF_PAGE.

    • CLEAR GS_LINE.

    • GS_LINE-TYP = 'A'.

**

    • GS_LINE-INFO = 'ACTION'.

    • APPEND GS_LINE TO GT_TOP_OF_PAGE.

*ENDFORM.

*FORM TOP_OF_PAGE.

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

  • WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.

*ENDFORM.

*FORM END_OF_PAGE.

  • WRITE at (sy-linsz) sy-pagno CENTERED.

*ENDFORM.

    • PRINT SETTINGS

*FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.

  • LS_PRINT-PRINT = P_PRINT. "PRINT IMMEDIATE

  • LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF. "NO SELECTION INFO

  • LS_PRINT-NO_COVERPAGE = P_NOCOVE. "NO COVER PAGE

  • LS_PRINT-NO_NEW_PAGE = P_NONEWP.

  • LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO

  • LS_PRINT-RESERVE_LINES = P_RESERV.

*ENDFORM.

**END OF ZALV PROGRAM

*REPORT ALV.

    • REPORT Z_LIST_MATERIALS.

TYPE-POOLS: SLIS.

TABLES:MARC, MARD, VBAP, LIPS, EKPO, VBFA, EKBE, MARM, VBBE, MARA, MBEW.

SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_WERKS FOR MARC-WERKS, " Plant

S_MATNR FOR MARC-MATNR, " Material

S_MTART FOR MARA-MTART. " Material Type

SELECTION-SCREEN END OF BLOCK SEL.

PARAMETERS: P_VARI LIKE DISvariant-VARIANT. " ALV Variant

CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA: BEGIN OF INV OCCURS 100,

WERKS LIKE MARD-WERKS, " Plant

MATNR LIKE MARD-MATNR, " Material

MTART LIKE MARA-MTART, " Material Type

STPRS LIKE MBEW-STPRS, " Standard Price

AVAIL LIKE MARD-LABST, " Available

LABST LIKE MARD-LABST, " Unrestricted use

INSME LIKE MARD-INSME, " Quality Inspection

RETME LIKE MARD-RETME, " Returns

TRANS LIKE MARC-UMLMC, " Stock in transit (calculated)

UMLMC LIKE MARC-UMLMC, " Stock Transfer (plant)

UMLME LIKE MARD-UMLME, " Transfer (SLoc)

WESBS LIKE EKBE-WESBS, " GR Blocked Stock

TRAME LIKE MARC-TRAME, " Stock in transit

SPEME LIKE MARD-SPEME, " Blocked

KWMENG LIKE VBAP-KWMENG, " Sales orders

LFIMG LIKE LIPS-LFIMG, " Scheduled for Delivery

MENGE LIKE EKPO-MENGE, " Open Purch. Orders

VALUE LIKE MBEW-SALK3, " Stock Value (Calculated)

MEINS LIKE MARA-MEINS, " Unit of measure

END OF INV.

DATA: FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,

HEADING TYPE SLIS_T_LISTHEADER,

LAYOUT TYPE SLIS_LAYOUT_ALV,

EVENTS TYPE SLIS_T_EVENT,

REPNAME LIKE SY-REPID,

F2CODE LIKE SY-UCOMM VALUE '&ETA',

G_SAVE(1) TYPE C,

G_EXIT(1) TYPE C,

G_VARIANT LIKE DISVARIANT,

GX_VARIANT LIKE DISVARIANT.

*break-point.

INITIALIZATION.

REPNAME = SY-REPID.

PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].

PERFORM BUILD_EVENTTAB USING EVENTS[].

PERFORM BUILD_COMMENT USING HEADING[].

PERFORM INITIALIZE_VARIANT.

*break-point.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.

PERFORM F4_FOR_VARIANT.

*break-point.

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

*break-point.

START-OF-SELECTION.

PERFORM GET_MARD.

PERFORM GET_UNIT_OF_MEASURE.

PERFORM GET_MARC.

PERFORM GET_EKPO.

PERFORM GET_LIPS.

PERFORM GET_VBAP.

PERFORM GET_OPEN.

PERFORM GET_PRICE.

END-OF-SELECTION.

*break-point.

PERFORM BUILD_LAYOUT USING LAYOUT.

PERFORM WRITE_OUTPUT.

&----


*& Form INITIALIZE_FIELDCAT

&----


  • text

----


  • -->P_FIELDTAB[] text *

----


FORM INITIALIZE_FIELDCAT USING P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.

DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

  • fixed columns (obligatory)

CLEAR L_FIELDCAT.

L_FIELDCAT-TABNAME = 'INV'.

L_FIELDCAT-FIX_COLUMN = 'X'.

L_FIELDCAT-NO_OUT = 'O'.

L_FIELDCAT-FIELDNAME = 'WERKS'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'MATNR'.

APPEND L_FIELDCAT TO P_FIELDTAB.

  • totalized columns

CLEAR L_FIELDCAT.

L_FIELDCAT-TABNAME = 'INV'.

L_FIELDCAT-SP_GROUP = 'A'.

L_FIELDCAT-DO_SUM = 'X'.

L_FIELDCAT-FIELDNAME = 'LABST'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'INSME'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'RETME'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'UMLME'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'WESBS'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'SPEME'.

APPEND L_FIELDCAT TO P_FIELDTAB.

  • columns with different description

L_FIELDCAT-FIELDNAME = 'KWMENG'.

L_FIELDCAT-SELTEXT_M = 'Sales Orders'.

L_FIELDCAT-SELTEXT_S = 'Sales Or'.

L_FIELDCAT-SELTEXT_L = 'Sales Orders Qty'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'LFIMG'.

L_FIELDCAT-SELTEXT_M = 'Sched. Delivery'.

L_FIELDCAT-SELTEXT_S = 'Schd. Del'.

L_FIELDCAT-SELTEXT_L = 'Scheduled for Delivery'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'TRANS'.

L_FIELDCAT-SELTEXT_M = 'Stk. in transit'.

L_FIELDCAT-SELTEXT_S = 'Stk. trns'.

L_FIELDCAT-SELTEXT_L = 'Stock in transit (sum)'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'AVAIL'.

L_FIELDCAT-SELTEXT_M = 'Available'.

L_FIELDCAT-SELTEXT_S = 'Avail.'.

L_FIELDCAT-SELTEXT_L = 'Stock Available'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'MENGE'.

L_FIELDCAT-SELTEXT_M = 'Open Orders'.

L_FIELDCAT-SELTEXT_S = 'Open Ord'.

L_FIELDCAT-SELTEXT_L = 'Open Purchase Orders'.

APPEND L_FIELDCAT TO P_FIELDTAB.

  • columns not displayed

CLEAR L_FIELDCAT.

L_FIELDCAT-TABNAME = 'INV'.

L_FIELDCAT-SP_GROUP = 'A'.

L_FIELDCAT-NO_OUT = 'X'.

L_FIELDCAT-FIELDNAME = 'MEINS'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'UMLMC'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'TRAME'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'STPRS'.

APPEND L_FIELDCAT TO P_FIELDTAB.

L_FIELDCAT-FIELDNAME = 'VALUE'.

APPEND L_FIELDCAT TO P_FIELDTAB.

ENDFORM. " INITIALIZE_FIELDCAT

&----


*& Form BUILD_EVENTTAB

&----


  • text

----


  • -->P_EVENTS[] text *

----


FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P_EVENTS.

READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO P_EVENTS.

ENDIF.

ENDFORM. " BUILD_EVENTTAB

&----


*& Form BUILD_COMMENT

&----


  • text

----


  • -->P_HEADING[] text *

----


FORM BUILD_COMMENT USING P_HEADING TYPE SLIS_T_LISTHEADER.

DATA: HLINE TYPE SLIS_LISTHEADER,

TEXT(60) TYPE C,

SEP(20) TYPE C.

CLEAR: HLINE, TEXT.

HLINE-TYP = 'H'.

WRITE: TEXT-101 TO TEXT+23.

HLINE-INFO = TEXT.

APPEND HLINE TO P_HEADING.

CLEAR TEXT.

WRITE: 'User: ' TO TEXT,

SY-UNAME TO TEXT+6,

'Date: ' TO TEXT+25,

SY-DATUM TO TEXT+31,

'Page: ' TO TEXT+50,

SY-PAGNO TO TEXT+56.

HLINE-INFO = TEXT.

APPEND HLINE TO P_HEADING.

ENDFORM. " BUILD_COMMENT

----


  • FORM TOP_OF_PAGE *

----


  • ........ *

----


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEADING.

ENDFORM.

&----


*& Form INITIALIZE_VARIANT

&----


  • text

----


<b>FORM INITIALIZE_VARIANT.

G_SAVE = 'A'.

CLEAR G_VARIANT.

G_VARIANT-REPORT = REPNAME.

GX_VARIANT = G_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 2.

IF SY-SUBRC = 0.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

ENDFORM. " INITIALIZE_VARIANT</b>&----


*& Form F4_FOR_VARIANT

&----


  • text

----


FORM F4_FOR_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = G_VARIANT

I_SAVE = G_SAVE

IMPORTING

E_EXIT = G_EXIT

ES_VARIANT = GX_VARIANT

EXCEPTIONS

NOT_FOUND = 2.

IF SY-SUBRC = 2.

MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

IF G_EXIT = SPACE.

P_VARI = GX_VARIANT-VARIANT.

ENDIF.

ENDIF.

ENDFORM. " F4_FOR_VARIANT

&----


*& Form PAI_OF_SELECTION_SCREEN

&----


  • text

----


FORM PAI_OF_SELECTION_SCREEN.

*

IF NOT P_VARI IS INITIAL.

MOVE G_VARIANT TO GX_VARIANT.

MOVE P_VARI TO GX_VARIANT-VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT.

G_VARIANT = GX_VARIANT.

ELSE.

PERFORM INITIALIZE_VARIANT.

ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

&----


*& Form GET_MARD

&----


  • text

----


FORM GET_MARD.

SELECT MATNR WERKS LABST INSME RETME UMLME SPEME

FROM MARD

INTO corresponding fields of INV

WHERE MATNR IN S_MATNR

AND WERKS IN S_WERKS.

COLLECT INV.

ENDSELECT.

PERFORM FILTER_BY_MATERIAL_TYPE.

ENDFORM. " GET_MARD

&----


*& Form FILTER_BY_MATERIAL_TYPE

&----


  • text

----


FORM FILTER_BY_MATERIAL_TYPE.

LOOP AT INV.

CLEAR INV-MTART.

SELECT SINGLE MTART

INTO INV-MTART

FROM MARA

WHERE MATNR EQ INV-MATNR

AND MTART IN S_MTART.

IF SY-SUBRC EQ 0.

MODIFY INV.

ELSE.

DELETE INV.

ENDIF.

ENDLOOP.

ENDFORM. " FILTER_BY_MATERIAL_TYPE

&----


*& Form GET_MARC

&----


  • text

----


FORM GET_MARC.

LOOP AT INV.

SELECT SINGLE UMLMC TRAME

FROM MARC

INTO CORRESPONDING FIELDS OF INV

WHERE MATNR EQ INV-MATNR

AND WERKS EQ INV-WERKS.

IF SY-SUBRC EQ 0.

INV-TRANS = INV-UMLMC + INV-TRAME.

MODIFY INV.

ENDIF.

ENDLOOP.

ENDFORM. " GET_MARC

&----


*& Form GET_EKPO

&----


  • text

----


FORM GET_EKPO.

DATA: WESBS LIKE INV-WESBS,

SHKZG LIKE EKBE-SHKZG,

MEINS LIKE EKPO-MEINS,

LMEIN LIKE EKPO-LMEIN.

LOOP AT INV.

CLEAR: WESBS, SHKZG, MEINS, LMEIN.

SELECT YWESBS YSHKZG XMEINS XLMEIN

INTO (WESBS, SHKZG, MEINS, LMEIN)

FROM EKPO AS X JOIN EKBE AS Y

ON XEBELN = YEBELN

AND XEBELP = YEBELP

WHERE X~MATNR EQ INV-MATNR

AND X~WERKS EQ INV-WERKS

AND X~LOEKZ NE 'L'.

IF SHKZG EQ 'H'.

MULTIPLY WESBS BY -1.

ENDIF.

IF MEINS NE LMEIN.

PERFORM CONVERT_UNIT_OF_MEASURE CHANGING INV-MATNR MEINS WESBS.

ENDIF.

ADD WESBS TO INV-WESBS.

ENDSELECT.

MODIFY INV.

ENDLOOP.

ENDFORM. " GET_EKPO

&----


*& Form GET_LIPS

&----


  • text

----


FORM GET_LIPS.

DATA: LFIMG LIKE INV-LFIMG.

LOOP AT INV.

CLEAR: LFIMG, INV-LFIMG.

SELECT OMENG

INTO LFIMG

FROM VBBE

WHERE MATNR EQ INV-MATNR

AND WERKS EQ INV-WERKS

AND VBTYP EQ 'J'.

ADD LFIMG TO INV-LFIMG.

ENDSELECT.

MODIFY INV.

ENDLOOP.

ENDFORM. " GET_LIPS

&----


*& Form GET_VBAP

&----


  • text

----


FORM GET_VBAP.

DATA: KWMENG LIKE INV-KWMENG.

LOOP AT INV.

CLEAR: KWMENG, INV-KWMENG.

SELECT OMENG

INTO KWMENG

FROM VBBE

WHERE MATNR EQ INV-MATNR

AND WERKS EQ INV-WERKS

AND VBTYP EQ 'C'.

ADD KWMENG TO INV-KWMENG.

ENDSELECT.

INV-AVAIL = INV-LABST - INV-INSME - INV-KWMENG - INV-LFIMG.

MODIFY INV.

ENDLOOP.

ENDFORM. " GET_VBAP

&----


*& Form GET_UNIT_OF_MEASURE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_UNIT_OF_MEASURE.

LOOP AT INV.

SELECT SINGLE MEINS

FROM MARA

INTO INV-MEINS

WHERE MATNR EQ INV-MATNR.

MODIFY INV.

ENDLOOP.

ENDFORM. " GET_UNIT_OF_MEASURE

&----


*& Form GET_OPEN

&----


  • text

----


FORM GET_OPEN.

DATA: BEGIN OF XTAB OCCURS 10, " Open orders table

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

MATNR LIKE EKPO-MATNR,

MENGE LIKE EKPO-MENGE,

MENGK LIKE EKPO-MENGE,

END OF XTAB.

RANGES: L_WERKS FOR MARD-WERKS.

LOOP AT INV.

REFRESH XTAB.

CLEAR: XTAB, L_WERKS.

MOVE INV-WERKS TO L_WERKS-LOW.

CALL FUNCTION 'MB_ADD_PURCHASE_ORDER_QUANTITY'

EXPORTING

X_MATNR = INV-MATNR

X_MEINS = INV-MEINS

X_ELIKZ = SPACE

X_LOEKZ = SPACE

TABLES

XTAB = XTAB

XWERKS = L_WERKS.

MOVE XTAB-MENGE TO INV-MENGE.

MODIFY INV.

ENDLOOP.

ENDFORM. " GET_OPEN

&----


*& Form GET_PRICE

&----


  • text

----


FORM GET_PRICE.

LOOP AT INV.

SELECT SINGLE STPRS

FROM MBEW

INTO INV-STPRS

WHERE MATNR EQ INV-MATNR

AND BWKEY EQ INV-WERKS

AND BWTAR EQ SPACE.

IF SY-SUBRC EQ 0.

INV-VALUE = INV-STPRS *

( INV-LABST + INV-INSME + INV-TRANS + INV-SPEME ).

MODIFY INV.

ENDIF.

ENDLOOP.

ENDFORM. " GET_PRICE

----


  • FORM CONVERT_UNIT_OF_MEASURE *

----


  • text *

----


  • --> P_MATNR *

  • --> P_VRKME *

  • --> P_QUANT *

----


FORM CONVERT_UNIT_OF_MEASURE USING P_MATNR P_VRKME P_QUANT.

DATA: UMREZ LIKE MARM-UMREZ,

UMREN LIKE MARM-UMREN.

SELECT SINGLE UMREZ UMREN

INTO (UMREZ, UMREN)

FROM MARM

WHERE MATNR EQ P_MATNR

AND MEINH EQ P_VRKME.

IF SY-SUBRC EQ 0.

COMPUTE P_QUANT = ( P_QUANT * UMREZ ) / UMREN.

ENDIF.

ENDFORM.

&----


*& Form BUILD_LAYOUT

&----


  • text

----


  • -->P_LAYOUT text *

----


FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.

P_LAYOUT-F2CODE = F2CODE.

P_LAYOUT-ZEBRA = 'X'.

P_LAYOUT-DETAIL_POPUP = 'X'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form WRITE_OUTPUT

&----


  • text

----


FORM WRITE_OUTPUT.

SORT INV BY WERKS MATNR.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = 'REPNAME'

I_INTERNAL_TABNAME = 'INV'

I_INCLNAME = 'REPNAME'

CHANGING

CT_FIELDCAT = FIELDTAB.

  • IF SY-SUBRC <> 0.

  • WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.

  • ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'REPNAME'

I_STRUCTURE_NAME = 'INV'

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDTAB

I_DEFAULT = 'A'

I_SAVE = G_SAVE

IS_VARIANT = G_VARIANT

IT_EVENTS = EVENTS[]

TABLES

T_OUTTAB = INV.