Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
REPORT sample LINE-COUNT 100 LINE-SIZE 900 NO
STANDARD PAGE HEADING.
LOAD-OF-PROGRAM.
TABLES: eina, "Purchasing Info Record: General Data
eine, "Purchasing Info Record: Purchasing Organization
a017, "Material Info Record (Plant-Specific)
konp, "Conditions (Item)
konm.
DATA g_tdname LIKE thead-tdname.
DATA g_count TYPE i.
DATA tot TYPE i.
DATA tot1 TYPE i.
DATA tot2 TYPE i.
DATA tot3 TYPE i.
DATA counter TYPE i.
DATA g_netpr LIKE eine-netpr.
DATA ig_read LIKE tline OCCURS 0 WITH HEADER LINE.
DATA ig_read1 LIKE tline OCCURS 0 WITH HEADER LINE.
DATA ig_thead LIKE thead OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF ig_text_type,
a TYPE i,
infnr LIKE eina-infnr,
line TYPE tline,
END OF ig_text_type.
DATA ig_text LIKE ig_text_type OCCURS 0 WITH HEADER LINE.
DATA: cont TYPE REF TO cl_gui_custom_container,
alv1 TYPE REF TO cl_gui_alv_grid,
alv2 TYPE REF TO cl_gui_alv_grid,
alv3 TYPE REF TO cl_gui_alv_grid,
g_fcat TYPE lvc_t_fcat,
w_fcat TYPE lvc_s_fcat,
g1_fcat TYPE lvc_t_fcat,
w1_fcat TYPE lvc_s_fcat,
gs_layout TYPE lvc_s_layo,
g3_fcat TYPE lvc_t_fcat,
w3_fcat TYPE lvc_s_fcat.
DATA splitter TYPE REF TO cl_gui_splitter_container.
DATA container1 TYPE REF TO cl_gui_container.
DATA container2 TYPE REF TO cl_gui_container.
DATA container3 TYPE REF TO cl_gui_container.
TYPES : BEGIN OF t_ig_eina_eine,
a TYPE i,
infnr LIKE eina-infnr,
anzpu LIKE eina-anzpu,
idnlf LIKE eina-idnlf,
kolif LIKE eina-kolif,
lifab LIKE eina-lifab,
lifbi LIKE eina-lifbi,
lifnr LIKE eina-lifnr,
lmein LIKE eina-lmein,
ltsnr LIKE eina-ltsnr,
ltssf LIKE eina-ltssf,
mahn1 LIKE eina-mahn1,
mahn2 LIKE eina-mahn2,
mahn3 LIKE eina-mahn3,
matkl LIKE eina-matkl,
matnr LIKE eina-matnr,
meins LIKE eina-meins,
mfrnr LIKE eina-mfrnr,
regio LIKE eina-regio,
relif LIKE eina-relif,
rueck LIKE eina-rueck,
telf1 LIKE eina-telf1,
umren LIKE eina-umren,
umrez LIKE eina-umrez,
urzdt LIKE eina-urzdt,
urzla LIKE eina-urzla,
urznr LIKE eina-urznr,
urztp LIKE eina-urztp,
urzzt LIKE eina-urzzt,
vabme LIKE eina-vabme,
verkf LIKE eina-verkf,
wglif LIKE eina-wglif,
angdt LIKE eine-angdt,
angnr LIKE eine-angnr,
aplfz LIKE eine-aplfz,
bprme LIKE eine-bprme,
bpumn LIKE eine-bpumn,
bpumz LIKE eine-bpumz,
bstae LIKE eine-bstae,
bstma LIKE eine-bstma,
effpr LIKE eine-effpr,
ekgrp LIKE eine-ekgrp,
ekkol LIKE eine-ekkol,
ekorg LIKE eine-ekorg,
esokz LIKE eine-esokz,
evers LIKE eine-evers,
exprf LIKE eine-exprf,
inco1 LIKE eine-inco1,
inco2 LIKE eine-inco2,
iprkz LIKE eine-iprkz,
kzabs LIKE eine-kzabs,
megru LIKE eine-megru,
meprf LIKE eine-meprf,
mhdrz LIKE eine-mhdrz,
minbm LIKE eine-minbm,
mtxno LIKE eine-mtxno,
mwskz LIKE eine-mwskz,
netpr LIKE eine-netpr,
norbm LIKE eine-norbm,
peinh LIKE eine-peinh,
prdat LIKE eine-prdat,
rdprf LIKE eine-rdprf,
sktof LIKE eine-sktof,
uebtk LIKE eine-uebtk,
uebto LIKE eine-uebto,
untto LIKE eine-untto,
waers LIKE eine-waers,
webre LIKE eine-webre,
werks1 LIKE eine-werks,
knumh LIKE konp-knumh,
kbetr LIKE konp-kbetr,
konwa LIKE konp-konwa,
kpein LIKE konp-kpein,
kmein LIKE konp-kmein,
kznep LIKE konp-kznep,
zterm LIKE konp-zterm,
valdt LIKE konp-valdt,
datab LIKE a017-datab,
datbi LIKE a017-datbi,
werks LIKE a017-werks,
mmsta LIKE marc-mmsta,
tdline LIKE tline-tdline,
kstbm LIKE konm-kstbm,
kbetrm LIKE konm-kbetr,
tcode(5) TYPE c,
END OF t_ig_eina_eine.
DATA ig_eina_eine TYPE t_ig_eina_eine OCCURS 0 WITH HEADER LINE.
DATA ig_new TYPE t_ig_eina_eine OCCURS 0 WITH HEADER LINE.
DATA: g_matnr LIKE ig_new-matnr,
g_lifnr LIKE ig_new-lifnr,
g_werks LIKE ig_new-werks,
g_ekorg LIKE ig_new-ekorg,
g_datab LIKE ig_new-datab,
g_datbi LIKE ig_new-datbi,
g_esokz LIKE ig_new-esokz.
DATA: l_matnr LIKE ig_new-matnr,
l_lifnr LIKE ig_new-lifnr,
l_werks LIKE ig_new-werks,
l_ekorg LIKE ig_new-ekorg,
l_datab LIKE ig_new-datab,
l_datbi LIKE ig_new-datbi,
l_esokz LIKE ig_new-esokz.
** CREATE INTERNAL TABLE FROM KONP TABLE FIELDS
DATA: BEGIN OF ig_konp OCCURS 0,
knumh LIKE konp-knumh,
kbetr LIKE konp-kbetr,
konwa LIKE konp-konwa,
kpein LIKE konp-kpein,
kmein LIKE konp-kmein,
kznep LIKE konp-kznep,
zterm LIKE konp-zterm,
valdt LIKE konp-valdt,
lifnr LIKE a017-lifnr,
matnr LIKE a017-matnr,
werks LIKE a017-werks,
datbi LIKE a017-datbi,
datab LIKE a017-datab,
END OF ig_konp.
* CREATE INTERNAL TABLE FROM A017 TABLE FIELDS
DATA: BEGIN OF ig_a017 OCCURS 0 ,
lifnr LIKE a017-lifnr,
matnr LIKE a017-matnr,
werks LIKE a017-werks,
datbi LIKE a017-datbi,
datab LIKE a017-datab,
knumh LIKE a017-knumh,
END OF ig_a017.
CLEAR ig_a017.
TYPES : BEGIN OF ig_konmt,
kstbm TYPE konm-kstbm,
knumh TYPE konm-knumh,
kbetr TYPE konm-kbetr,
END OF ig_konmt.
DATA ig_konm TYPE STANDARD TABLE OF ig_konmt.
CLEAR ig_konm.
DATA wa_igkonm LIKE LINE OF ig_konm.
CLEAR wa_igkonm.
TYPES : BEGIN OF t_ig_scale,
c TYPE i,
matnr LIKE eina-matnr,
lifnr LIKE eina-lifnr,
werks LIKE eine-werks,
datab LIKE a017-datab,
datbi LIKE a017-datbi,
kstbm LIKE konm-kstbm,
kbetr LIKE konm-kbetr,
END OF t_ig_scale.
DATA ig_scale TYPE t_ig_scale OCCURS 0 WITH HEADER LINE.
* data wa_scale like line of ig_scale.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS p_datbi LIKE a017-datbi.
PARAMETERS p_prdat LIKE eine-prdat.
PARAMETERS p_mmsta LIKE marc-mmsta.
*Parameters test type c.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS s_matnr FOR eina-matnr.
SELECT-OPTIONS s_werks FOR eine-werks.
SELECTION-SCREEN : END OF BLOCK b2.
*---------------------------------------------------------------------*
* CLASS inforecord DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS inforecord DEFINITION.
PUBLIC SECTION.
CLASS-METHODS class_constructor.
METHODS: constructor.
METHODS : select_query,
loop_operation,
serial_no,
table_scale,
field_catalog.
CLASS-DATA : d_infrec TYPE string,
d_text TYPE string,
m TYPE i VALUE 1,
tot TYPE i,
tot1 TYPE i,
g_count TYPE i.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS INFORECORD IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS inforecord IMPLEMENTATION.
METHOD class_constructor.
TYPES : BEGIN OF ig_konmt,
kstbm TYPE konm-kstbm,
knumh TYPE konm-knumh,
kbetr TYPE konm-kbetr,
END OF ig_konmt.
DATA ig_konm TYPE STANDARD TABLE OF ig_konmt.
DATA wa_igkonm LIKE LINE OF ig_konm.
ENDMETHOD.
METHOD constructor.
PERFORM selection_values.
ENDMETHOD.
METHOD select_query.
PERFORM tab_einaeine.
PERFORM tab_a017.
PERFORM tab_konm.
PERFORM tab_konp.
ENDMETHOD.
METHOD loop_operation.
PERFORM loop_a017.
PERFORM loop_einaeine.
PERFORM loop_textdisplay.
PERFORM loop_final.
ENDMETHOD.
METHOD serial_no.
PERFORM des_alv.
ENDMETHOD.
METHOD table_scale.
PERFORM scale.
ENDMETHOD.
METHOD field_catalog.
PERFORM catalog1.
PERFORM catalog2 .
PERFORM catalog3.
ENDMETHOD.
ENDCLASS.
* Classical Processing Blocks
START-OF-SELECTION.
DATA info TYPE REF TO inforecord.
CREATE OBJECT info.
CALL METHOD info->select_query .
CALL METHOD info->loop_operation.
CALL METHOD info->serial_no.
CALL METHOD info->table_scale.
CALL METHOD info->field_catalog.
CALL SCREEN 202.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Module STATUS_0202 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0202 OUTPUT.
SET PF-STATUS 'SCREEN_205'.
SET TITLEBAR 'TITLE'.
IF cont IS INITIAL.
CREATE OBJECT cont
EXPORTING container_name = 'CONTAINER'.
CREATE OBJECT splitter
EXPORTING
* LINK_DYNNR =
* LINK_REPID =
* SHELLSTYLE =
* LEFT =
* TOP =
* WIDTH =
* HEIGHT =
* METRIC = cntl_metric_dynpro
* ALIGN = 15
parent = cont
rows = 3
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
* EXCEPTIONS
* CNTL_ERROR = 1
* CNTL_SYSTEM_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.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container1.
CALL METHOD splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = container2.
CALL METHOD splitter->get_container
EXPORTING
row = 3
column = 1
RECEIVING
container = container3.
CREATE OBJECT alv1
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = container1
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_USE_VARIANT_CLASS = SPACE
* I_NAME =
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT alv2
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = container2
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_USE_VARIANT_CLASS = SPACE
* I_NAME =
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT alv3
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = container3
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_USE_VARIANT_CLASS = SPACE
* I_NAME =
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD alv1->set_table_for_first_display
EXPORTING
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
* it_outtab = ig_eina_eine[]
it_outtab = ig_new[]
it_fieldcatalog = g_fcat
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD alv2->set_table_for_first_display
EXPORTING
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'zstr4'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = ig_text[]
it_fieldcatalog = g1_fcat
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD alv3->set_table_for_first_display
EXPORTING
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = ig_scale[]
it_fieldcatalog = g3_fcat
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0202 OUTPUT
*&---------------------------------------------------------------------*
*& Module CANCEL INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE cancel INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " CANCEL INPUT
*---------------------------------------------------------------------*
* FORM TAB_EINAEINE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM tab_einaeine.
SELECT DISTINCT a~infnr a~anzpu a~idnlf a~kolif a~lifab a~lifbi a~lifnr
a~lmein
a~ltsnr a~ltssf a~mahn1 a~mahn2 a~mahn3 a~matkl a~matnr a~meins
a~mfrnr a~regio a~relif a~rueck a~telf1 a~umren a~umrez a~urzdt
a~urzla a~urznr a~urztp a~urzzt a~vabme a~verkf a~wglif b~angdt
b~angnr b~aplfz b~bprme b~bpumn b~bpumz b~bstae b~bstma b~effpr
b~ekgrp b~ekkol b~ekorg b~esokz b~evers b~exprf b~inco1 b~inco2
b~iprkz b~kzabs b~megru b~meprf b~mhdrz b~minbm b~mtxno b~mwskz
b~netpr
b~norbm b~peinh b~prdat b~rdprf b~sktof b~uebtk b~uebto b~untto
b~waers b~webre b~werks c~mmsta
INTO
CORRESPONDING FIELDS OF
TABLE
ig_eina_eine
FROM ( ( eina AS a INNER JOIN eine AS b ON a~infnr = b~infnr )
INNER JOIN marc AS c ON a~matnr = c~matnr )
WHERE b~werks IN s_werks
AND b~ekorg EQ '4001' AND
a~matnr IN s_matnr AND
a~loekz EQ ' '
AND c~lvorm <> 'X'
AND b~prdat >= p_prdat.
ENDFORM.
*select fields from konp on condition based
FORM tab_konp.
SELECT knumh kbetr konwa kpein kmein kznep zterm valdt lifnr
INTO TABLE ig_konp
FROM konp
FOR ALL ENTRIES IN ig_a017
WHERE knumh = ig_a017-knumh.
APPEND ig_konp.
* clear ig_konp.
ENDFORM.
*select fields from a017 on condition based
FORM tab_a017.
SELECT lifnr matnr werks datbi datab knumh
INTO TABLE ig_a017
FROM a017
WHERE werks IN s_werks AND ekorg = '4001' .
APPEND ig_a017.
ENDFORM.
*---------------------------------------------------------------------*
* FORM TAB_KONM *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM tab_konm.
SELECT kstbm knumh kbetr
INTO wa_igkonm
FROM konm FOR ALL ENTRIES IN ig_konp
WHERE knumh = ig_konp-knumh.
APPEND wa_igkonm TO ig_konm.
ENDSELECT.
ENDFORM.
* Compare two internal tables and fetch fields based on conditions
FORM loop_a017.
LOOP AT ig_a017.
IF ig_a017-matnr <> ''.
READ TABLE ig_konp WITH KEY knumh = ig_a017-knumh.
IF sy-subrc = 0.
ig_konp-datab = ig_a017-datab.
ig_konp-datbi = ig_a017-datbi.
ig_konp-werks = ig_a017-werks.
ig_konp-matnr = ig_a017-matnr.
ig_konp-lifnr = ig_a017-lifnr.
MODIFY ig_konp TRANSPORTING lifnr matnr werks datab datbi
WHERE knumh = ig_konp-knumh .
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM LOOP_EINAEINE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM loop_einaeine.
LOOP AT ig_eina_eine.
ig_eina_eine-werks = '4301'.
MODIFY ig_eina_eine TRANSPORTING werks.
READ TABLE ig_konp WITH KEY lifnr = ig_eina_eine-lifnr
matnr = ig_eina_eine-matnr .
IF sy-subrc = 0.
ig_eina_eine-knumh = ig_konp-knumh.
ig_eina_eine-kbetr = ig_konp-kbetr.
ig_eina_eine-konwa = ig_konp-konwa.
ig_eina_eine-kpein = ig_konp-kpein.
ig_eina_eine-kmein = ig_konp-kmein.
ig_eina_eine-kznep = ig_konp-kznep.
ig_eina_eine-zterm = ig_konp-zterm.
ig_eina_eine-valdt = ig_konp-valdt.
ig_eina_eine-datab = ig_konp-datab.
ig_eina_eine-datbi = ig_konp-datbi.
MODIFY ig_eina_eine TRANSPORTING knumh kbetr konwa kpein kmein kznep
zterm valdt datab datbi kstbm kstbm kbetrm
WHERE lifnr = ig_eina_eine-lifnr
AND matnr = ig_eina_eine-matnr.
CLEAR ig_konp.
ENDIF.
READ TABLE ig_konm INTO wa_igkonm WITH KEY knumh = ig_eina_eine-knumh.
IF sy-subrc = 0.
ig_eina_eine-kstbm = wa_igkonm-kstbm.
ig_eina_eine-kbetrm = wa_igkonm-kbetr.
MODIFY ig_eina_eine TRANSPORTING kstbm kbetrm.
ENDIF.
ENDLOOP.
ENDFORM.
*To generate serial number for the alv1
FORM des_alv.
DESCRIBE TABLE ig_eina_eine LINES tot.
LOOP AT ig_eina_eine.
ig_eina_eine-a = sy-tabix.
MODIFY ig_eina_eine TRANSPORTING a.
IF sy-tabix > tot.
EXIT.
ENDIF.
ENDLOOP.
* *To generate serial number for the alv1
DESCRIBE TABLE ig_text LINES tot1.
LOOP AT ig_text.
ig_text-a = sy-tabix.
MODIFY ig_text TRANSPORTING a.
IF sy-tabix > tot1.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
*---------------------------------------------------------------------*
* FORM catalog1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM catalog1.
*ASSIGNING VALUES TO FIELD CATALOG FOR IG_NEW.
DEFINE catalog_first.
w_fcat-tabname = &1.
w_fcat-fieldname = &2.
w_fcat-coltext = &3.
w_fcat-outputlen = &4.
append w_fcat to g_fcat.
END-OF-DEFINITION.
catalog_first 'IG_NEW' 'A' 'S.NO' '5'.
catalog_first 'IG_NEW' 'INFNR' 'INFNR' '10'.
catalog_first 'IG_NEW' 'MATNR' 'MATNR' '10'.
catalog_first 'IG_NEW' 'LIFNR' 'LIFNR' '10'.
catalog_first 'IG_NEW' 'EKORG' 'EKORG' '10'.
catalog_first 'IG_NEW' 'WERKS' 'WERKS' '10'.
catalog_first 'IG_NEW' 'UMREZ' 'UMREZ' '10'.
catalog_first 'IG_NEW' 'UMREN' 'UMREN' '10'.
catalog_first 'IG_NEW' 'IDNLF' 'IDNLF' '10'.
catalog_first 'IG_NEW' 'VERKF' 'VERKF' '10'.
catalog_first 'IG_NEW' 'TELF1' 'TELF1' '10'.
catalog_first 'IG_NEW' 'MAHN1' 'MAHN1' '10'.
catalog_first 'IG_NEW' 'MAHN2' 'MAHN2' '10'.
catalog_first 'IG_NEW' 'MAHN3' 'MAHN3' '10'.
catalog_first 'IG_NEW' 'URZNR' 'URZNR' '10'.
catalog_first 'IG_NEW' 'URZLA' 'URZLA' '10'.
catalog_first 'IG_NEW' 'URZTP' 'URZTP' '10'.
catalog_first 'IG_NEW' 'URZZT' 'URZZT' '10'.
catalog_first 'IG_NEW' 'REGIO' 'REGIO' '10'.
catalog_first 'IG_NEW' 'VABME' 'VABME' '10'.
catalog_first 'IG_NEW' 'LTSSF' 'LTSSF' '10'.
catalog_first 'IG_NEW' 'WGLIF' 'WGLIF' '10'.
catalog_first 'IG_NEW' 'RUECK' 'RUECK' '10'.
catalog_first 'IG_NEW' 'LIFAB' 'LIFAB' '10'.
catalog_first 'IG_NEW' 'LIFBI' 'LIFBI' '10'.
catalog_first 'IG_NEW' 'KOLIF' 'KOLIF' '10'.
catalog_first 'IG_NEW' 'ANZPU' 'ANZPU' '10'.
catalog_first 'IG_NEW' 'RELIF' 'RELIF' '10'.
catalog_first 'IG_NEW' 'MFRNR' 'MFRNR' '10'.
catalog_first 'IG_NEW' 'WAERS' 'WAERS' '10'.
catalog_first 'IG_NEW' 'MINBM' 'MINBM' '10'.
catalog_first 'IG_NEW' 'NORBM' 'NORBM' '10'.
catalog_first 'IG_NEW' 'APLFZ' 'APLFZ' '10'.
catalog_first 'IG_NEW' 'UEBTO' 'UEBTO' '10'.
catalog_first 'IG_NEW' 'UEBTK' 'UEBTK' '10'.
catalog_first 'IG_NEW' 'UNTTO' 'UNTTO' '10'.
catalog_first 'IG_NEW' 'ANGNR' 'ANGNR' '10'.
catalog_first 'IG_NEW' 'ANGDT' 'ANGDT' '10'.
w_fcat-tabname = 'IG_NEW'.
w_fcat-fieldname = 'NETPR'.
w_fcat-coltext = 'NETPR'.
w_fcat-outputlen = '10'.
w_fcat-do_sum = 'NETPR'.
APPEND w_fcat TO g_fcat.
catalog_first 'IG_NEW' 'VABME' 'VABME' '10'.
catalog_first 'IG_NEW' 'LTSNR' 'LTSNR' '10'.
catalog_first 'IG_NEW' 'PEINH' 'PEINH' '10'.
catalog_first 'IG_NEW' 'PRDAT' 'PRDAT' '10'.
catalog_first 'IG_NEW' 'BPUMZ' 'BPUMZ' '10'.
catalog_first 'IG_NEW' 'MTXNO' 'MTXNO' '10'.
catalog_first 'IG_NEW' 'WEBRE' 'WEBRE' '10'.
catalog_first 'IG_NEW' 'EKKOL' 'EKKOL' '10'.
catalog_first 'IG_NEW' 'SKTOF' 'SKTOF' '10'.
catalog_first 'IG_NEW' 'KZABS' 'KZABS' '10'.
catalog_first 'IG_NEW' 'MWSKZ' 'MWSKZ' '10'.
catalog_first 'IG_NEW' 'EVERS' 'EVERS' '10'.
catalog_first 'IG_NEW' 'EXPRF' 'EXPRF' '10'.
catalog_first 'IG_NEW' 'BSTAE' 'BSTAE' '10'.
catalog_first 'IG_NEW' 'MEPRF' 'MEPRF' '10'.
catalog_first 'IG_NEW' 'INCO1' 'INCO1' '10'.
catalog_first 'IG_NEW' 'INCO2' 'INCO2' '10'.
catalog_first 'IG_NEW' 'ANGNR' 'ANGNR' '10'.
catalog_first 'IG_NEW' 'ANGDT' 'ANGDT' '10'.
catalog_first 'IG_NEW' 'NETPR' 'NETPR' '10'.
catalog_first 'IG_NEW' 'VABME' 'VABME' '10'.
catalog_first 'IG_NEW' 'LTSNR' 'LTSNR' '10'.
catalog_first 'IG_NEW' 'MHDRZ' 'MHDRZ' '10'.
catalog_first 'IG_NEW' 'BSTMA' 'BSTMA' '10'.
catalog_first 'IG_NEW' 'RDPRF' 'RDPRF' '10'.
catalog_first 'IG_NEW' 'MEGRU' 'MEGRU' '10'.
catalog_first 'IG_NEW' 'DATAB' 'DATAB' '10'.
catalog_first 'IG_NEW' 'DATBI' 'DATBI' '10'.
catalog_first 'IG_NEW' 'KBETR' 'KBETR' '10'.
catalog_first 'IG_NEW' 'KONWA' 'KONWA' '10'.
catalog_first 'IG_NEW' 'KPEIN' 'KPEIN' '10'.
catalog_first 'IG_NEW' 'KMEIN' 'KMEIN' '10'.
catalog_first 'IG_NEW' 'KZNEP' 'KZNEP' '10'.
catalog_first 'IG_NEW' 'VALDT' 'VALDT' '10'.
catalog_first 'IG_NEW' 'ZTERM' 'ZTERM' '10'.
catalog_first 'IG_NEW' 'BPRME' 'BPRME' '10'.
catalog_first 'IG_NEW' 'BPUMN' 'BPUMN' '10'.
catalog_first 'IG_NEW' 'EFFPR' 'EFFPR' '10'.
catalog_first 'IG_NEW' 'EKGRP' 'EKGRP' '10'.
catalog_first 'IG_NEW' 'ESOKZ' 'ESOKZ' '10'.
catalog_first 'IG_NEW' 'IPRKZ' 'IPRKZ' '10'.
catalog_first 'IG_NEW' 'KNUMH' 'KNUMH' '10'.
catalog_first 'IG_NEW' 'LMEIN' 'LMEIN' '10'.
catalog_first 'IG_NEW' 'MATNR' 'MATNR' '10'.
catalog_first 'IG_NEW' 'MEINS' 'MEINS' '10'.
catalog_first 'IG_NEW' 'WERKS1' 'WERKS1' '10'.
catalog_first 'IG_NEW' 'MMSTA' 'MMSTA' '10'.
catalog_first 'IG_NEW' 'KNUMH' 'KNUMH' '10'.
catalog_first 'IG_NEW' 'TCODE' 'TCODE' '10'.
*SERIAL NUMBER.
DESCRIBE TABLE ig_new LINES tot2.
LOOP AT ig_new.
ig_new-a = sy-tabix.
MODIFY ig_new TRANSPORTING a.
IF sy-tabix > tot2.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
*Assigning values to field catalog for alv2
FORM catalog2.
DEFINE catalog_second.
w1_fcat-fieldname = &1.
w1_fcat-tabname = &2.
w1_fcat-coltext = &3.
w1_fcat-outputlen = &4.
append w1_fcat to g1_fcat.
END-OF-DEFINITION.
gs_layout-zebra = 'X'.
catalog_second 'A' 'IG_TEXT' 'S.NO' '5'.
catalog_second 'INFNR' 'IG_TEXT' 'INFNR' '10'.
catalog_second 'LINE' 'IG_TEXT' 'TEXT' '10'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM LOOP_TEXTDISPLAY *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM loop_textdisplay.
LOOP AT ig_eina_eine.
* PERFORM display.
g_tdname = ig_eina_eine-infnr.
CLEAR ig_read[].
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'AT'
language = sy-langu
name = g_tdname
object = 'EINA'
TABLES
lines = ig_read
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
LOOP AT ig_read.
ig_text-infnr = g_tdname.
ig_text-line = ig_read-tdline.
APPEND ig_text.
CLEAR ig_text.
ENDLOOP.
CLEAR ig_read1[].
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'BT'
language = sy-langu
name = g_tdname
object = 'EINE'
TABLES
lines = ig_read1
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
g_count = 800.
LOOP AT ig_read1.
ig_text-infnr = g_tdname.
ig_text-line = ig_read1-tdline.
APPEND ig_text.
CLEAR ig_text.
ENDLOOP.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form selection_values
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selection_values.
* s_werks-sign = 'I'.
* s_werks-option = 'EQ'.
* s_werks-low = '4000'.
* APPEND s_werks.
* CLEAR s_werks.
* s_werks-sign = 'I'.
* s_werks-option = 'EQ'.
* s_werks-low = '4003'.
* APPEND s_werks.
* CLEAR s_werks.
* s_werks-sign = 'I'.
* s_werks-option = 'EQ'.
* s_werks-low = '4006'.
* APPEND s_werks.
* CLEAR s_werks.
* s_werks-sign = 'I'.
* s_werks-option = 'EQ'.
* s_werks-low = '4008'.
* APPEND s_werks.
* CLEAR s_werks.
* s_werks-sign = 'I'.
* s_werks-option = 'EQ'.
* s_werks-low = '4046'.
* APPEND s_werks.
* CLEAR s_werks.
* s_werks-sign = 'I'.
* s_werks-option = 'EQ'.
* s_werks-low = '90'.
* APPEND s_werks.
* CLEAR s_werks.
ENDFORM. " selection_values
*---------------------------------------------------------------------*
* FORM scale *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM scale.
LOOP AT ig_new.
LOOP AT ig_konm INTO wa_igkonm WHERE knumh = ig_new-knumh.
ig_scale-kstbm = wa_igkonm-kstbm.
ig_scale-kbetr = wa_igkonm-kbetr.
ig_scale-matnr = ig_new-matnr.
ig_scale-lifnr = ig_new-lifnr.
ig_scale-werks = ig_new-werks.
ig_scale-datab = ig_new-datab.
ig_scale-datbi = ig_new-datbi.
APPEND ig_scale.
ENDLOOP.
ENDLOOP.
DESCRIBE TABLE ig_scale LINES tot3.
LOOP AT ig_scale.
ig_scale-c = sy-tabix.
MODIFY ig_scale TRANSPORTING c.
IF sy-tabix > tot3.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
" scale
*&---------------------------------------------------------------------*
*& Form catalog3
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM catalog3.
DEFINE catalog_third.
w3_fcat-fieldname = &1.
w3_fcat-tabname = &2.
w3_fcat-coltext = &3.
w3_fcat-outputlen = &4.
append w3_fcat to g3_fcat.
END-OF-DEFINITION.
catalog_third 'C' 'IG_SCALE' 'S.NO' '5'.
catalog_third 'MATNR' 'IG_SCALE' 'MATNR' '10'.
catalog_third 'LIFNR' 'IG_SCALE' 'LIFNR' '10'.
catalog_third 'WERKS' 'IG_SCALE' 'WERKS' '10'.
catalog_third 'DATAB' 'IG_SCALE' 'DATAB' '10'.
catalog_third 'DATBI' 'IG_SCALE' 'DATBI' '10'.
catalog_third 'KSTBM' 'IG_SCALE' 'KSTBM' '10'.
catalog_third 'KBETR' 'IG_SCALE' 'KBETR' '10'.
ENDFORM. " catalog3
*&---------------------------------------------------------------------*
*& Form loop_final
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM loop_final.
LOOP AT ig_a017.
IF ig_a017-matnr <> ''.
READ TABLE ig_eina_eine WITH KEY matnr = ig_a017-matnr lifnr =
ig_a017-lifnr.
IF sy-subrc = 0.
ig_new-ekorg = ig_eina_eine-ekorg.
ig_new-matnr = ig_eina_eine-matnr.
ig_new-untto = ig_eina_eine-untto.
ig_new-infnr = ig_eina_eine-infnr.
ig_new-lifnr = ig_eina_eine-lifnr.
ig_new-werks = ig_eina_eine-werks.
ig_new-umrez = ig_eina_eine-umrez.
ig_new-idnlf = ig_eina_eine-idnlf.
ig_new-verkf = ig_eina_eine-verkf.
ig_new-telf1 = ig_eina_eine-telf1.
ig_new-mahn1 = ig_eina_eine-mahn1.
ig_new-mahn2 = ig_eina_eine-mahn2.
ig_new-mahn3 = ig_eina_eine-mahn3.
ig_new-urznr = ig_eina_eine-urznr.
ig_new-urzdt = ig_eina_eine-urzdt.
ig_new-urzla = ig_eina_eine-urzla.
ig_new-urztp = ig_eina_eine-urztp.
ig_new-urzzt = ig_eina_eine-urzzt.
ig_new-regio = ig_eina_eine-regio.
ig_new-vabme = ig_eina_eine-vabme.
ig_new-ltsnr = ig_eina_eine-ltsnr.
ig_new-ltssf = ig_eina_eine-ltssf.
ig_new-wglif = ig_eina_eine-wglif.
ig_new-rueck = ig_eina_eine-rueck.
ig_new-lifab = ig_eina_eine-lifab.
ig_new-lifbi = ig_eina_eine-lifbi.
ig_new-kolif = ig_eina_eine-kolif.
ig_new-anzpu = ig_eina_eine-anzpu.
ig_new-relif = ig_eina_eine-relif.
ig_new-mfrnr = ig_eina_eine-mfrnr.
ig_new-waers = ig_eina_eine-waers.
ig_new-minbm = ig_eina_eine-minbm.
ig_new-norbm = ig_eina_eine-norbm.
ig_new-minbm = ig_eina_eine-minbm.
ig_new-aplfz = ig_eina_eine-aplfz.
ig_new-uebto = ig_eina_eine-uebto.
ig_new-uebtk = ig_eina_eine-uebtk.
ig_new-angnr = ig_eina_eine-angnr.
ig_new-angdt = ig_eina_eine-angdt.
ig_new-netpr = ig_eina_eine-netpr.
ig_new-peinh = ig_eina_eine-peinh.
ig_new-prdat = ig_eina_eine-prdat.
ig_new-bpumz = ig_eina_eine-bpumz.
ig_new-mtxno = ig_eina_eine-mtxno.
ig_new-webre = ig_eina_eine-webre.
ig_new-ekkol = ig_eina_eine-ekkol.
ig_new-sktof = ig_eina_eine-sktof.
ig_new-kzabs = ig_eina_eine-kzabs.
ig_new-mwskz = ig_eina_eine-mwskz.
ig_new-evers = ig_eina_eine-evers.
ig_new-exprf = ig_eina_eine-exprf.
ig_new-bstae = ig_eina_eine-bstae.
ig_new-meprf = ig_eina_eine-meprf.
ig_new-inco1 = ig_eina_eine-inco1.
ig_new-inco2 = ig_eina_eine-inco2.
ig_new-mhdrz = ig_eina_eine-mhdrz.
ig_new-bstma = ig_eina_eine-bstma.
ig_new-rdprf = ig_eina_eine-rdprf.
ig_new-megru = ig_eina_eine-megru.
ig_new-konwa = ig_eina_eine-konwa.
ig_new-kpein = ig_eina_eine-kpein.
ig_new-kmein = ig_eina_eine-kmein.
ig_new-kznep = ig_eina_eine-kznep.
ig_new-valdt = ig_eina_eine-valdt.
ig_new-zterm = ig_eina_eine-zterm.
ig_new-bprme = ig_eina_eine-bprme.
ig_new-effpr = ig_eina_eine-effpr.
ig_new-ekgrp = ig_eina_eine-ekgrp.
ig_new-esokz = ig_eina_eine-esokz.
ig_new-iprkz = ig_eina_eine-iprkz.
ig_new-lmein = ig_eina_eine-lmein.
ig_new-lmein = ig_eina_eine-lmein.
ig_new-werks1 = ig_eina_eine-werks1.
ig_new-datab = ig_eina_eine-datab.
ig_new-datbi = ig_eina_eine-datbi.
ig_new-knumh = ig_eina_eine-knumh.
ENDIF.
ig_new-datab = ig_a017-datab.
ig_new-lifnr = ig_a017-lifnr.
ig_new-matnr = ig_a017-matnr.
ig_new-werks = ig_a017-werks.
ig_new-datbi = ig_a017-datbi.
ig_new-datab = ig_a017-datab.
ig_new-knumh = ig_a017-knumh.
READ TABLE ig_konp WITH KEY matnr = ig_a017-matnr.
IF sy-subrc = 0.
ig_new-kbetr = ig_konp-kbetr.
ig_new-konwa = ig_konp-konwa.
ig_new-kpein = ig_konp-kpein.
ig_new-kmein = ig_konp-kmein.
ig_new-kznep = ig_konp-kznep.
ig_new-zterm = ig_konp-zterm.
ig_new-valdt = ig_konp-valdt.
ENDIF.
APPEND ig_new.
ENDIF.
ENDLOOP.
SORT ig_new BY matnr lifnr werks ekorg datab datbi esokz.
CLEAR: g_matnr,g_lifnr,g_werks,g_datab,g_datbi,g_esokz.
CLEAR counter.
LOOP AT ig_new.
counter = counter + 1.
IF counter = 1.
g_matnr = ig_new-matnr.
g_lifnr = ig_new-lifnr.
g_werks = ig_new-werks.
g_datab = ig_new-datab.
g_datbi = ig_new-datbi.
g_esokz = ig_new-esokz.
IF g_matnr = ig_new-matnr AND g_lifnr = ig_new-lifnr AND g_werks =
ig_new-werks AND g_datab = ig_new-datab AND g_datbi = ig_new-datbi
AND g_esokz = ig_new-esokz.
ig_new-tcode = 'ME11'.
MODIFY ig_new TRANSPORTING tcode.
ENDIF.
ENDIF.
IF counter <> 1.
IF ig_new-matnr <> l_matnr OR ig_new-lifnr <> l_lifnr OR
ig_new-werks <> l_werks OR ig_new-esokz <> l_esokz OR
ig_new-ekorg
<> l_ekorg.
ig_new-tcode = 'ME11'.
MODIFY ig_new TRANSPORTING tcode.
ENDIF.
ENDIF.
* assigning values to loop variable.
l_matnr = ig_new-matnr.
l_lifnr = ig_new-lifnr.
l_werks = ig_new-werks .
l_datab = ig_new-datab .
l_datbi = ig_new-datbi.
l_esokz = ig_new-esokz.
l_ekorg = ig_new-ekorg.
ENDLOOP.
ENDFORM. " loop_final
  • No labels

1 Comment

  1. Former Member

    Hello, thanks a lot for posting your code.

    I'm trying to look at your program and I'm having some difficulties understanding OO parts. Would you be so kind to post some screenshots of screen 202 (you defined PF_STATUS_205, but there is no reference to any functionality) and/or some documentation (how transaction ME11 is executed)?

    Best Regards,  Maria