Code: Alles auswählen.
TYPES: BEGIN OF t_tab,
matnr(10) TYPE c,
werks(10) TYPE c,
maktx(10) TYPE c,
etc(20) TYPE c,
END OF t_tab.
DATA: w_tab TYPE t_tab,
i_tab TYPE TABLE OF t_tab.
START-OF-SELECTION.
w_tab-werks = 'C1000'.
w_tab-matnr = '10001'.
w_tab-maktx = 'KURZ1'.
w_tab-etc = 'kdkladf..ljkadkf'.
APPEND w_tab TO i_tab.
w_tab-werks = 'C2000'.
w_tab-matnr = '10001'.
w_tab-maktx = 'KURZ2'.
w_tab-etc = 'kdkladf..ljkadkf'.
APPEND w_tab TO i_tab.
w_tab-werks = 'C1300'.
w_tab-matnr = '10001'.
w_tab-maktx = 'KURZ3'.
w_tab-etc = 'kdkladf..ljkadkf'.
APPEND w_tab TO i_tab.
w_tab-werks = 'C1000'.
w_tab-matnr = '10002'.
w_tab-maktx = 'KURZ1'.
w_tab-etc = 'kdkladf..ljkadkf'.
APPEND w_tab TO i_tab.
SORT i_tab BY matnr.
LOOP AT i_tab INTO w_tab.
AT NEW matnr.
WRITE: / w_tab-matnr.
ENDAT.
WRITE w_tab-werks.
ENDLOOP.
Code: Alles auswählen.
data begin of wmat.
data matnr type matnr.
data werke type table of werks_d.
data end of wmat.
data tmat like table of wmat.
Code: Alles auswählen.
* TMAT wurde mit Materialnummern gefüllt
loop at tmat into wmat.
loop at tab_marc into marc
where matnr = wmat-matnr.
append marc-werks to wmat-werke.
endloop.
endloop.
Code: Alles auswählen.
* TMAT wurde mit Materialnummern gefüllt
loop at tmat into wmat.
loop at tab_marc into marc
where matnr = wmat-matnr.
append marc-werks to wmat-werke.
endloop.
modify tmat from wmat.
endloop.
Code: Alles auswählen.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE,
it_line TYPE standard table of tline with header line,
w_line TYPE tline,
w_header TYPE thead,
w_name TYPE THEAD-TDNAME,
w_maktx TYPE makt-maktx,
w_werks2 TYPE marc-werks.
Code: Alles auswählen.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke like table of marc-werks,
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE,
it_line TYPE standard table of tline with header line,
w_line TYPE tline,
w_header TYPE thead,
w_name TYPE THEAD-TDNAME,
w_maktx TYPE makt-maktx,
w_werks2 TYPE marc-werks.
Code: Alles auswählen.
loop at it_tab.
select werks into table it_tab-tab_werke
from marc where matnr = it_tab-matnr.
modify it_tab.
endloop.
Code: Alles auswählen.
loop at it_tab.
write: / it_tab-matnr,
it_tab-mtart,
it_tab-maktx.
loop at it_tab-tab_werke into w_werks2.
write w_werks2.
endloop.
endloop.
Code: Alles auswählen.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke like table of marc-werks,
END OF ty_tab.
Code: Alles auswählen.
REPORT ZMM_TEXTE LINE-SIZE 400 NO STANDARD PAGE HEADING.
TABLES : mara, stxl, eina, eine, makt, marc.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke like table of marc-werks,
END OF ty_tab.
DATA : p_spras TYPE spras.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE,
it_line TYPE standard table of tline with header line,
w_line TYPE tline,
w_header TYPE thead,
w_name TYPE THEAD-TDNAME,
w_maktx TYPE makt-maktx,
w_werks2 TYPE string,
tmat like table of it_tab.
DATA: w_tdline TYPE string.
DATA w_tdstring TYPE string.
DATA w_st_werks1 TYPE string.
DATA w_st_werks2 TYPE string.
DATA text_tab like tline occurs 0 with header line.
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK ZMM WITH FRAME TITLE text-t01.
SELECT-OPTIONS : s_matnr FOR mara-matnr default '10001',
" Material number
s_mtart FOR mara-mtart, " Material type
s_werks FOR eine-werks. " Plant
PARAMETERS : s_tdid LIKE stxl-tdid default 'BEST'. " Text type
SELECTION-SCREEN END OF BLOCK ZMM.
SELECTION-SCREEN BEGIN OF BLOCK ZMM1 WITH FRAME TITLE text-t02.
PARAMETERS P_LY1 RADIOBUTTON GROUP FORM. " German
PARAMETERS P_LY2 RADIOBUTTON GROUP FORM. " English
PARAMETERS P_LY3 RADIOBUTTON GROUP FORM. " French
SELECTION-SCREEN END OF BLOCK ZMM1.
IF P_LY1 = 'X'.
p_spras = 'DE'.
ELSEIF P_LY2 = 'X'.
p_spras = 'EN'.
ELSEIF P_LY3 = 'X'.
p_spras = 'FR'.
ENDIF.
START-OF-SELECTION.
SELECT mara~matnr mara~mtart makt~maktx marc~werks
* INTO CORRESPONDING FIELDS OF table it_tab
FROM ( ( ( mara
INNER JOIN STXL ON STXL~TDNAME = mara~matnr AND
STXL~TDID = s_tdid AND
STXL~TDSPRAS = p_spras )
INNER JOIN MAKT ON MAKT~MATNR = mara~matnr )
INNER JOIN MARC ON MARC~MATNR = mara~matnr )
INTO (it_tab-matnr, it_tab-mtart, it_tab-maktx, it_tab-werks2)
WHERE mara~matnr IN s_matnr AND
mtart IN s_mtart.
APPEND it_tab.
ENDSELECT.
Loop at it_tab.
w_st_werks1 = it_tab-werks2.
concatenate w_st_werks2 w_st_werks1 into w_st_werks2.
delete it_tab from 1 to 99 where werks2 = w_st_werks1.
endloop.
******************************************************************
*PROZESS TEXTART "BEST" *
******************************************************************
LOOP at it_tab.
clear : it_line[], w_header.
move it_tab-matnr to w_name.
move it_tab-maktx to w_maktx.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = s_tdid
language = p_spras
name = w_name
object = 'MATERIAL'
archive_handle = 0
local_cat = ' '
*IMPORTING
* HEADER = thead[]
tables
lines = text_tab
* lines = text_tab
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR text_tab.
CLEAR w_tdstring.
LOOP AT text_tab.
w_tdline = text_tab-tdline.
CONDENSE w_tdline.
CONCATENATE w_tdstring w_tdline into w_tdstring separated by space.
ENDLOOP.
CONDENSE w_tdstring.
SHIFT w_name LEFT DELETING LEADING '0'.
WRITE: / w_name(12).
WRITE: it_tab-werks2.
WRITE: w_maktx.
WRITE: ' ', w_tdstring.
ENDLOOP.
Code: Alles auswählen.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke like table of marc-werks,
END OF ty_tab.
Code: Alles auswählen.
DATA : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke like table of marc-werks,
END OF ty_tab.
Code: Alles auswählen.
data : begin of it_tab occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
maktx like makt-maktx,
tab_werke like table of marc-werks,
end of it_tab.
Code: Alles auswählen.
select mara~matnr mara~mtart makt~maktx
into (it_tab-matnr, it_tab-mtart, it_tab-maktx)
from ( ( mara inner join stxl on stxl~tdname = mara~matnr
and stxl~tdid = s_tdid
and stxl~tdspras = p_spras )
inner join makt on makt~matnr = mara~matnr )
where mara~matnr in s_matnr
and mtart in s_mtart.
select werks into table it_tab-tab_werke
from marc where matnr = it_tab-matnr.
append it_tab.
endselect.
* Loop at it_tab.
* w_st_werks1 = it_tab-werks2.
* concatenate w_st_werks2 w_st_werks1
* into w_st_werks2.
* delete it_tab from 1 to 99
* where werks2 = w_st_werks1.
* endloop.
Code: Alles auswählen.
TYPES tab_werke_typ TYPE SORTED TABLE OF werks
WITH UNIQUE KEY werks.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke TYPE tab_werke_typ,
END OF ty_tab.
Code: Alles auswählen.
REPORT zmm_texte LINE-SIZE 400 NO STANDARD PAGE HEADING.
TABLES : mara, stxl, eina, eine, makt, marc.
TYPES tab_werke_typ TYPE SORTED TABLE OF werks
WITH UNIQUE KEY werks.
TYPES : BEGIN OF ty_tab,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
tab_werke TYPE tab_werke_typ,
END OF ty_tab.
DATA : p_spras TYPE spras.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE,
it_line TYPE STANDARD TABLE OF tline WITH HEADER LINE,
w_line TYPE tline,
w_header TYPE thead,
w_name TYPE thead-tdname,
w_maktx TYPE makt-maktx,
w_werks2 TYPE string,
tmat LIKE TABLE OF it_tab.
* Arbeitsstruktur für die WERKS-Struktur
DATA werks TYPE werks.
DATA: w_tdline TYPE string.
DATA w_tdstring TYPE string.
DATA w_st_werks1 TYPE string.
DATA w_st_werks2 TYPE string.
DATA text_tab LIKE tline OCCURS 0 WITH HEADER LINE.
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK zmm WITH FRAME TITLE text-t01.
SELECT-OPTIONS : s_matnr FOR mara-matnr DEFAULT '10001',
" Material number
s_mtart FOR mara-mtart, " Material type
s_werks FOR eine-werks. " Plant
PARAMETERS : s_tdid LIKE stxl-tdid DEFAULT 'BEST'. " Text type
SELECTION-SCREEN END OF BLOCK zmm.
SELECTION-SCREEN BEGIN OF BLOCK zmm1 WITH FRAME TITLE text-t02.
PARAMETERS p_ly1 RADIOBUTTON GROUP form. " German
PARAMETERS p_ly2 RADIOBUTTON GROUP form. " English
PARAMETERS p_ly3 RADIOBUTTON GROUP form. " French
SELECTION-SCREEN END OF BLOCK zmm1.
IF p_ly1 = 'X'.
p_spras = 'DE'.
ELSEIF p_ly2 = 'X'.
p_spras = 'EN'.
ELSEIF p_ly3 = 'X'.
p_spras = 'FR'.
ENDIF.
START-OF-SELECTION.
**** Auf diese Art bekommst Du zuviele Einträge in der ITAB!
* SELECT mara~matnr mara~mtart makt~maktx marc~werks
** INTO CORRESPONDING FIELDS OF table it_tab
* FROM ( ( ( mara
* INNER JOIN stxl ON stxl~tdname = mara~matnr AND
* stxl~tdid = s_tdid AND
* stxl~tdspras = p_spras )
* INNER JOIN makt ON makt~matnr = mara~matnr )
* INNER JOIN marc ON marc~matnr = mara~matnr )
* INTO (it_tab-matnr, it_tab-mtart, it_tab-maktx, it_tab-werks2)
*
* WHERE mara~matnr IN s_matnr AND
* mtart IN s_mtart.
* APPEND it_tab.
* ENDSELECT.
*** Zuerst nur die MARA lesen (mit Existenzcheck auf die anderen Tabs)
SELECT mara~matnr mara~mtart makt~maktx
FROM mara INNER JOIN makt ON makt~matnr = mara~matnr
INTO (IT_TAB-MATNR, IT_TAB-MTART, IT_TAB-MAKTX)
WHERE mara~matnr IN s_matnr AND
mtart IN s_mtart AND
* Um Texte zu finden, immer über die Kopftabelle STXH gehen!
* Wegen Performance nie das Textobjekt weglassen!
exists ( SELECT * FROM stxh WHERE tdobject = 'MATERIAL' AND
tdname = mara~matnr AND
tdid = s_tdid AND
tdspras = p_spras ) AND
exists ( SELECT * FROM marc WHERE matnr = mara~matnr ).
APPEND it_tab.
ENDSELECT.
**** Damit ändert sich auch dieser Loop:
* LOOP AT it_tab.
*
* w_st_werks1 = it_tab-werks2.
*
* CONCATENATE w_st_werks2 w_st_werks1 INTO w_st_werks2.
*
* DELETE it_tab FROM 1 TO 99 WHERE werks2 = w_st_werks1.
* ENDLOOP.
LOOP AT it_tab.
SELECT werks INTO TABLE it_tab-tab_werke FROM marc
WHERE matnr = it_tab-matnr.
MODIFY it_tab.
ENDLOOP.
******************************************************************
*PROZESS TEXTART "BEST" *
******************************************************************
LOOP AT it_tab.
CLEAR : it_line[], w_header.
MOVE it_tab-matnr TO w_name.
MOVE it_tab-maktx TO w_maktx.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = s_tdid
language = p_spras
name = w_name
object = 'MATERIAL'
archive_handle = 0
local_cat = ' '
*IMPORTING
* HEADER = thead[]
TABLES
lines = text_tab
* lines = text_tab
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR text_tab.
CLEAR w_tdstring.
LOOP AT text_tab.
w_tdline = text_tab-tdline.
CONDENSE w_tdline.
CONCATENATE w_tdstring w_tdline INTO w_tdstring SEPARATED BY space.
ENDLOOP.
CONDENSE w_tdstring.
SHIFT w_name LEFT DELETING LEADING '0'.
WRITE: / w_name(12).
**** An dieser Stelle der Loop zur Ausgabe:
* WRITE: it_tab-werks2.
LOOP AT it_tab-tab_werke INTO werks.
WRITE werks-werks.
ENDLOOP.
WRITE: w_maktx.
WRITE: ' ', w_tdstring.
ENDLOOP.