Skip to Content
0
Former Member
Mar 14, 2007 at 04:01 PM

default variants in ALV

47 Views

hello all,

i have written the following code. i have saved a couple of variants for the selection screen. now i want one of the variants to be displayed on the selection screen by default. i tried using REUSE_ALV_VARIANT_DEFAULT_GET. plz do check the below code and tell me the errors.

thanks in advance,

seenu

REPORT YSG_MATSTK_REPT LINE-SIZE 220

LINE-COUNT 50(5).

&----


*& DATA DECLARATION *

&----


TABLES: MARA, "GENERAL MASTER DATA

MARC, "PLANT DATA FOR MATERIAL

MARD, "STORAGE LOCATION DATA FOR MATERIAL

MBEW, "MATERIAL VALUATION

MVKE, "SALES DATA FOR MATERIAL

MAKT, "MATERIAL DESCRIPTION

EKKO, "PURCHASING DOCUMENT HEADER

EKPO, "PURCHASING DOCUMENT ITEM

VBAK, "SALES DOCUMENT HEADER DATA

VBAP. "SALES DOCUMENT ITEM DATA

TYPE-POOLS : SLIS.

DATA: VT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

V_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

V_LAYOUT TYPE SLIS_LAYOUT_ALV,

BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

BEGIN OF I_MARA OCCURS 0,

MATNR LIKE MARA-MATNR, "MATERIAL NUMBER

MBRSH LIKE MARA-MBRSH, "INDUSTRY SECTOR

MEINS LIKE MARA-MEINS, "BASE UNIT OF MEASURE

MATKL LIKE MARA-MATKL, "MATERIAL GROUP

END OF I_MARA,

BEGIN OF I_MARC OCCURS 0,

MATNR LIKE MARC-MATNR, "MATERIAL NUMBER

WERKS LIKE MARC-WERKS, "PLANT

LVORM LIKE MARC-LVORM, "FLAG MATERIAL FOR DELETION AT PLANT

"LEVEL

DISPO LIKE MARC-DISPO, "MRP CONTROLLER

END OF I_MARC,

BEGIN OF I_MAKT OCCURS 0,

MATNR LIKE MAKT-MATNR, "MATERIAL NUMBER

MAKTX LIKE MAKT-MAKTX, "MATERIAL DESCRIPTION

SPRAS LIKE MAKT-SPRAS, "LANGUAGE KEY

END OF I_MAKT,

BEGIN OF I_MVKE OCCURS 0,

MATNR LIKE MVKE-MATNR, "MATERIAL NUMBER

VKORG LIKE MVKE-VKORG, "SALES ORGANIZATION

VTWEG LIKE MVKE-VTWEG, "DISTRIBUTION CHANNEL

END OF I_MVKE,

BEGIN OF I_MARD OCCURS 0,

MATNR LIKE MARD-MATNR, "MATERIAL NUMBER

LGORT LIKE MARD-LGORT, "STORAGE LOCATION

LABST LIKE MARD-LABST, "VALUATED STOCK WITH UNRESTRICTED USE

END OF I_MARD,

BEGIN OF I_EKPO OCCURS 0,

EBELN LIKE EKPO-EBELN, "PURCHASING DOCUMENT NUMBER

EBELP LIKE EKPO-EBELP, "ITEM NUMBER OF PURCHASING DOCUMENT

MATNR LIKE EKPO-MATNR, "MATERIAL NUMBER

END OF I_EKPO,

BEGIN OF I_VBAP OCCURS 0,

VBELN LIKE VBAP-VBELN, "SALES DOCUMENT

POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM

MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER

END OF I_VBAP,

BEGIN OF I_OUT OCCURS 0,

MATNR LIKE MARC-MATNR,

WERKS LIKE MARC-WERKS,

LVORM LIKE MARC-LVORM,

DISPO LIKE MARC-DISPO,

MBRSH LIKE MARA-MBRSH,

MEINS LIKE MARA-MEINS,

MATKL LIKE MARA-MATKL,

VKORG LIKE MVKE-VKORG,

VTWEG LIKE MVKE-VTWEG,

SPRAS LIKE MAKT-SPRAS,

MAKTX LIKE MAKT-MAKTX,

LGORT LIKE MARD-LGORT,

LABST LIKE MARD-LABST,

EBELN LIKE EKPO-EBELN,

EBELP LIKE EKPO-EBELP,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

END OF I_OUT,

BEGIN OF I_HEADING OCCURS 0,

TEXT1(20),

TEXT2(20),

TEXT3(20),

TEXT4(20),

TEXT5(20),

TEXT6(20),

TEXT7(20),

TEXT8(20),

TEXT9(20),

TEXT10(20),

TEXT11(40),

TEXT12(20),

TEXT13(20),

TEXT14(20),

TEXT15(20),

TEXT16(20),

TEXT17(20),

END OF I_HEADING.

&----


*& S E L E C T I O N - S C R E E N *

&----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-100.

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. "OBLIGATORY.

PARAMETERS: P_WERKS LIKE MARC-WERKS. "OBLIGATORY.

SELECT-OPTIONS: S_LGORT FOR MARD-LGORT,

S_DISPO FOR MARC-DISPO,

S_EBELN FOR EKPO-EBELN .

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-101.

PARAMETERS : RB1 RADIOBUTTON GROUP G1,

RB2 RADIOBUTTON GROUP G1,

RB3 RADIOBUTTON GROUP G1.

SELECTION-SCREEN END OF BLOCK B2.

&----


*& I N I T I A L I Z A T I O N *

&----


INITIALIZATION.

data: g_save type c value 'X'.

data: g_variant type disvariant.

data: gx_variant type disvariant.

data: g_exit type c.

*data: ispfli type table of spfli.

parameters: variant like disvariant-variant.

at selection-screen output.

check variant is initial.

gx_variant-report = sy-repid.

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.

variant = gx_variant-variant.

endif.

&----


*& S T A R T - O F - S E L E C T I O N *

&----


START-OF-SELECTION.

SELECT MATNR WERKS LVORM DISPO FROM MARC

INTO CORRESPONDING FIELDS OF TABLE I_MARC

WHERE MATNR IN S_MATNR

AND DISPO IN S_DISPO

AND WERKS = P_WERKS.

IF I_MARC[] IS INITIAL.

WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARC'.

EXIT.

ENDIF.

PERFORM PURCHASEDATA_VALIDATION.

PERFORM SALESDATA_VALIDATION.

SELECT MATNR LGORT LABST FROM MARD INTO TABLE I_MARD

FOR ALL ENTRIES IN I_MARC

WHERE MATNR = I_MARC-MATNR

AND WERKS EQ P_WERKS

AND LGORT IN S_LGORT.

IF I_MARD[] IS INITIAL.

WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARD'.

EXIT.

ENDIF.

SELECT MATNR VKORG VTWEG FROM MVKE INTO TABLE I_MVKE

FOR ALL ENTRIES IN I_MARC

WHERE MATNR = I_MARC-MATNR.

IF I_MVKE[] IS INITIAL.

WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MVKE'.

EXIT.

ENDIF.

LOOP AT I_MARC.

MOVE-CORRESPONDING I_MARC TO I_OUT.

CLEAR MARC.

SELECT SINGLE MATNR MBRSH MEINS MATKL FROM MARA

INTO CORRESPONDING FIELDS OF MARA

WHERE MATNR = I_OUT-MATNR.

IF SY-SUBRC = 0.

MOVE: MARA-MBRSH TO I_OUT-MBRSH,

MARA-MEINS TO I_OUT-MEINS,

MARA-MATKL TO I_OUT-MATKL.

ELSE.

CONTINUE.

ENDIF.

SELECT SINGLE MATNR MAKTX SPRAS FROM MAKT

INTO CORRESPONDING FIELDS OF MAKT

WHERE MATNR = I_OUT-MATNR.

IF SY-SUBRC = 0.

MOVE: MAKT-MAKTX TO I_OUT-MAKTX,

MAKT-SPRAS TO I_OUT-SPRAS.

ELSE.

CONTINUE.

ENDIF.

LOOP AT I_EKPO WHERE MATNR = I_MARC-MATNR.

MOVE: I_EKPO-EBELN TO I_OUT-EBELN,

I_EKPO-EBELP TO I_OUT-EBELP.

ENDLOOP.

LOOP AT I_VBAP WHERE MATNR = I_MARC-MATNR.

MOVE: I_VBAP-VBELN TO I_OUT-VBELN,

I_VBAP-POSNR TO I_OUT-POSNR.

ENDLOOP.

LOOP AT I_MARD WHERE MATNR = I_MARC-MATNR.

MOVE: I_MARD-LABST TO I_OUT-LABST,

I_MARD-LGORT TO I_OUT-LGORT.

ENDLOOP.

LOOP AT I_MVKE WHERE MATNR = I_MARC-MATNR.

MOVE: I_MVKE-VKORG TO I_OUT-VKORG,

I_MVKE-VTWEG TO I_OUT-VTWEG.

APPEND I_OUT.

ENDLOOP.

CLEAR I_OUT.

ENDLOOP.

PERFORM OPTIONS.

----


  • FORM OPTIONS *

----


FORM OPTIONS.

IF RB2 = 'X'.

PERFORM FIELDCAT.

PERFORM OUTPUT.

ELSE.

IF RB1 = 'X'.

PERFORM HEADINGS.

PERFORM DLOAD.

ELSE.

IF RB3 = 'X'.

PERFORM HEADINGS.

PERFORM DLOAD.

PERFORM FIELDCAT.

PERFORM OUTPUT.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. "OPTIONS

----


  • FORM HEADINGS *

----


FORM HEADINGS.

I_HEADING-TEXT1 = 'MATNR'.

I_HEADING-TEXT2 = 'WERKS'.

I_HEADING-TEXT3 = 'LVORM'.

I_HEADING-TEXT4 = 'DISPO'.

I_HEADING-TEXT5 = 'MBRSH'.

I_HEADING-TEXT6 = 'MEINS'.

I_HEADING-TEXT7 = 'MATKL'.

I_HEADING-TEXT8 = 'VKORG'.

I_HEADING-TEXT9 = 'VTWEG'.

I_HEADING-TEXT10 = 'SPRAS'.

I_HEADING-TEXT11 = 'MAKTX'.

I_HEADING-TEXT12 = 'LGORT'.

I_HEADING-TEXT13 = 'LABST'.

I_HEADING-TEXT14 = 'EBELN'.

I_HEADING-TEXT15 = 'EBELP'.

I_HEADING-TEXT16 = 'VBELN'.

I_HEADING-TEXT17 = 'POSNR'.

APPEND I_HEADING.

ENDFORM. "HEADINGS

----


  • FORM DLOAD *

----


FORM DLOAD.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\MATSTK.XLS'

FILETYPE = 'DAT'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = I_HEADING

EXCEPTIONS

FILE_WRITE_ERROR = 1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\MATSTK.XLS'

FILETYPE = 'DAT'

APPEND = 'X'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = I_OUT.

ENDFORM. "DLOAD

----


  • FORM FIELDCAT *

----


FORM FIELDCAT.

V_FIELDCAT-COL_POS = '1'.

V_FIELDCAT-FIELDNAME = 'MATNR'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-HOTSPOT = 'X'.

V_FIELDCAT-REF_FIELDNAME = 'MATNR'.

V_FIELDCAT-REF_TABNAME = 'MARC'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '2'.

V_FIELDCAT-FIELDNAME = 'WERKS'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'WERKS'.

V_FIELDCAT-REF_TABNAME = 'MARC'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '3'.

V_FIELDCAT-FIELDNAME = 'LVORM'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'LVORM'.

V_FIELDCAT-REF_TABNAME = 'MARC'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '4'.

V_FIELDCAT-FIELDNAME = 'DISPO'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'DISPO'.

V_FIELDCAT-REF_TABNAME = 'MARC'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '5'.

V_FIELDCAT-FIELDNAME = 'MBRSH'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'MBRSH'.

V_FIELDCAT-REF_TABNAME = 'MARA'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '6'.

V_FIELDCAT-FIELDNAME = 'MEINS'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'MEINS'.

V_FIELDCAT-REF_TABNAME = 'MARA'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '7'.

V_FIELDCAT-FIELDNAME = 'MATKL'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'MATKL'.

V_FIELDCAT-REF_TABNAME = 'MARA'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '8'.

V_FIELDCAT-FIELDNAME = 'VKORG'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'VKORG'.

V_FIELDCAT-REF_TABNAME = 'MVKE'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '9'.

V_FIELDCAT-FIELDNAME = 'VTWEG'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'VTWEG'.

V_FIELDCAT-REF_TABNAME = 'MVKE'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '10'.

V_FIELDCAT-FIELDNAME = 'SPRAS'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'SPRAS'.

V_FIELDCAT-REF_TABNAME = 'MAKT'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '11'.

V_FIELDCAT-FIELDNAME = 'MAKTX'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'MAKTX'.

V_FIELDCAT-REF_TABNAME = 'MAKT'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '12'.

V_FIELDCAT-FIELDNAME = 'LGORT'.

V_FIELDCAT-TABNAME = 'I_OUT'.

  • V_FIELDCAT-REF_FIELDNAME = 'LGORT'.

  • V_FIELDCAT-REF_TABNAME = 'MARD'.

V_FIELDCAT-SELTEXT_L = 'STRG LOCT'.

V_FIELDCAT-OUTPUTLEN = 10.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '13'.

V_FIELDCAT-FIELDNAME = 'LABST'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-SELTEXT_M = 'STOCK'.

V_FIELDCAT-OUTPUTLEN = 15.

  • V_FIELDCAT-REF_FIELDNAME = 'LABST'.

  • V_FIELDCAT-REF_TABNAME = 'MARD'.

V_FIELDCAT-DO_SUM = 'X'.

V_LAYOUT-TOTALS_TEXT = 'TOTAL STOCK:'.

V_FIELDCAT-HOTSPOT = 'X'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '14'.

V_FIELDCAT-FIELDNAME = 'EBELN'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-HOTSPOT = 'X'.

V_FIELDCAT-REF_FIELDNAME = 'EBELN'.

V_FIELDCAT-REF_TABNAME = 'EKPO'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '15'.

V_FIELDCAT-FIELDNAME = 'EBELP'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'EBELP'.

V_FIELDCAT-REF_TABNAME = 'EKPO'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '16'.

V_FIELDCAT-FIELDNAME = 'VBELN'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-HOTSPOT = 'X'.

V_FIELDCAT-REF_FIELDNAME = 'VBELN'.

V_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

V_FIELDCAT-COL_POS = '17'.

V_FIELDCAT-FIELDNAME = 'POSNR'.

V_FIELDCAT-TABNAME = 'I_OUT'.

V_FIELDCAT-REF_FIELDNAME = 'POSNR'.

V_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND V_FIELDCAT TO VT_FIELDCAT1.

CLEAR V_FIELDCAT.

ENDFORM. "FIELDCAT

----


  • FORM OUTPUT *

----


FORM OUTPUT.

g_variant-report = sy-repid.

g_variant-variant = variant.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

I_GRID_TITLE = 'CLICK ON MATERIAL/PURDOC/SALESDOC FOR DETAILS'

I_CALLBACK_USER_COMMAND = 'DISPLAYDETAILS'

IS_LAYOUT = V_LAYOUT

IT_FIELDCAT = VT_FIELDCAT1

i_save = g_save

is_variant = g_variant

TABLES

T_OUTTAB = I_OUT.

IF SY-SUBRC <> 0.

ENDIF.

ENDFORM. "OUTPUT

----


  • FORM TOP-OF-PAGE *

----


FORM TOP-OF-PAGE.

DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

WA_HEADER TYPE SLIS_LISTHEADER.

WA_HEADER-TYP = 'H'.

WA_HEADER-INFO = 'REPORT FOR : '.

APPEND WA_HEADER TO T_HEADER.

CLEAR WA_HEADER.

WA_HEADER-TYP = 'S'.

WA_HEADER-INFO = 'MATERIAL DETAILS'.

APPEND WA_HEADER TO T_HEADER.

CLEAR WA_HEADER.

WA_HEADER-TYP = 'S'.

WA_HEADER-INFO = 'PURCHASE ORDER DETAILS'.

APPEND WA_HEADER TO T_HEADER.

CLEAR WA_HEADER.

WA_HEADER-TYP = 'S'.

WA_HEADER-INFO = 'SALES ORDER DETAILS'.

APPEND WA_HEADER TO T_HEADER.

CLEAR WA_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'GEAR'

IT_LIST_COMMENTARY = T_HEADER.

ENDFORM. "TOP-OF-PAGE

&----


*& FORM DISPLAYDETAILS *

&----


FORM DISPLAYDETAILS USING UCOMM LIKE SY-UCOMM

SELFIELD TYPE SLIS_SELFIELD.

IF SELFIELD-FIELDNAME = 'EBELN'.

IF UCOMM = '&IC1'.

READ TABLE I_OUT INDEX SELFIELD-TABINDEX.

PERFORM PORECDNG.

CLEAR BDCDATA[].

ENDIF.

ELSE.

IF SELFIELD-FIELDNAME = 'MATNR'.

IF UCOMM = '&IC1'.

READ TABLE I_OUT INDEX SELFIELD-TABINDEX.

PERFORM MMRECDNG.

CLEAR BDCDATA[].

ENDIF.

ELSE.

IF SELFIELD-FIELDNAME = 'VBELN'.

IF UCOMM = '&IC1'.

READ TABLE I_OUT INDEX SELFIELD-TABINDEX.

PERFORM SALESRECDNG.

CLEAR BDCDATA[].

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. "DISPLAYDETAILS

----


  • FORM PORECDNG *

----


FORM PORECDNG.

PERFORM BDC_DYNPRO USING 'SAPMM06E' '0105'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RM06E-BSTNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'RM06E-BSTNR'

I_OUT-EBELN.

PERFORM BDC_TRANSACTION USING 'ME23'.

ENDFORM. "PORECDNG

----


  • FORM MMRECDNG *

----


FORM MMRECDNG.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMMG1-MATNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'RMMG1-MATNR'

I_OUT-MATNR.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)'

'X'.

PERFORM BDC_TRANSACTION USING 'MM03'.

ENDFORM. "MMRECDNG

----


  • FORM SALESRECDNG *

----


FORM SALESRECDNG.

PERFORM BDC_DYNPRO USING 'SAPMV45A' '0102'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'VBAK-VBELN'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'VBAK-VBELN'

I_OUT-VBELN.

PERFORM BDC_TRANSACTION USING 'VA03'.

ENDFORM. "SALESRECDNG

----


  • FORM BDC_TRANSACTION *

----


FORM BDC_TRANSACTION USING TCODE.

CALL TRANSACTION TCODE USING BDCDATA MODE 'E'.

ENDFORM. "BDC_TRANSACTION

----


  • FORM BDC_DYNPRO *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "BDC_DYNPRO

----


  • INSERT FIELD *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM. "BDC_FIELD

&----


*& FORM PURCHASEDATA_VALIDATION *

&----


FORM PURCHASEDATA_VALIDATION.

SELECT EBELN EBELP MATNR

FROM EKPO

INTO TABLE I_EKPO

FOR ALL ENTRIES IN I_MARC

WHERE MATNR = I_MARC-MATNR

AND EBELN IN S_EBELN

AND WERKS EQ P_WERKS.

IF I_EKPO[] IS INITIAL.

WRITE:/ 'NO MATCHING DATA IS SELECTED FROM TABLE EKPO'.

EXIT.

ENDIF.

DATA: T_EKPO LIKE I_EKPO OCCURS 0 WITH HEADER LINE.

T_EKPO[] = I_EKPO[].

REFRESH I_EKPO.

FREE I_EKPO.

LOOP AT T_EKPO.

SELECT SINGLE EBELN FROM EKKO INTO EKPO-EBELN

WHERE EBELN = T_EKPO-EBELN.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING T_EKPO TO I_EKPO.

APPEND I_EKPO.

CLEAR I_EKPO.

ELSE.

CONTINUE.

ENDIF.

ENDLOOP.

SORT I_EKPO.

ENDFORM. "PURCHASEDATA_VALIDATION

&----


*& FORM SALESDATA_VALIDATION *

&----


FORM SALESDATA_VALIDATION.

SELECT VBELN POSNR MATNR

FROM VBAP

INTO CORRESPONDING FIELDS OF TABLE

I_VBAP FOR ALL ENTRIES IN I_MARC

WHERE MATNR = I_MARC-MATNR.

DATA: T_VBAP LIKE I_VBAP OCCURS 0 WITH HEADER LINE.

T_VBAP[] = I_VBAP[].

REFRESH I_VBAP.

FREE I_VBAP.

LOOP AT T_VBAP.

SELECT SINGLE VBELN FROM VBAK INTO VBAK-VBELN

WHERE VBELN = T_VBAP-VBELN.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING T_VBAP TO I_VBAP.

APPEND I_VBAP.

CLEAR I_VBAP.

ELSE.

CONTINUE.

ENDIF.

ENDLOOP.

SORT I_VBAP.

ENDFORM. "SALESDATA_VALIDATION