Ich meine ein Feld von der Struktur einer Tabellenzeile. Also das, was man gemeinhin seit zig Jahren meint, wenn man "workarea" im ABAP-Kontext sagt.kostonstyle hat geschrieben:was meinst du mit workarea? einfach variablen definieren?
Code: Alles auswählen.
LOOP AT tab_bseg ASSIGNING <tab_bseg>
WHERE bukrs = <tab_bkpf>-bukrs
AND belnr = <tab_bkpf>-belnr
AND gjahr = <tab_bkpf>-gjahr.
"***********************************"
" Datenfüllen für ALV GRID "
"***********************************"
MOVE <tab_ska1>-ktopl TO itab_output-ktopl.
MOVE <tab_ska1>-saknr TO itab_output-saknr.
MOVE <tab_ska1>-xbilk TO itab_output-xbilk.
MOVE <tab_skb1>-bukrs TO itab_output-bukrs.
MOVE <tab_bsis>-gjahr TO itab_output-gjahr.
MOVE <tab_bsis>-belnr TO itab_output-belnr.
MOVE <tab_bseg>-bschl TO itab_output-bschl.
MOVE <tab_bseg>-koart TO itab_output-koart.
MOVE <tab_bseg>-shkzg TO itab_output-shkzg.
MOVE <tab_bseg>-dmbtr TO itab_output-dmbtr.
MOVE <tab_bseg>-wrbtr TO itab_output-wrbtr.
MOVE <tab_bseg>-kostl TO itab_output-kostl.
MOVE <tab_bseg>-aufnr TO itab_output-aufnr.
MOVE <tab_bseg>-vbel2 TO itab_output-vbel2.
MOVE <tab_bseg>-posn2 TO itab_output-posn2.
MOVE <tab_bseg>-paobjnr TO itab_output-paobjnr.
APPEND itab_output TO tab_output.
Code: Alles auswählen.
ZERKONTO-DMBTR (Kombination Referenz-Tabelle/Feld BSEG-DMBTR ex. nicht)
ZERKONTO-WRBTR (Kombination Referenz-Tabelle/Feld BSEG-WRBTR ex. nicht)
Code: Alles auswählen.
REPORT zprogrammam.
TABLES: bseg,
zerkonto.
DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
g_container TYPE scrfname VALUE 'BCALV_GRID_CONTROL', "Dynproname
grid1 TYPE REF TO cl_gui_alv_grid, "ALV Grid Definition
ok_code LIKE sy-ucomm, "Bildschirmbilder, Funktionscode, der PAI ausgelöst hat
tab_output TYPE TABLE OF zerkonto.
INCLUDE z_dataset_in.
*----------------------------------------------------------------------*
* CLASS databasetrust DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS databasetrust DEFINITION.
PUBLIC SECTION.
CLASS-METHODS selektion.
CLASS-METHODS main.
PRIVATE SECTION.
***********************************
* TYPE Definition *
***********************************
TYPES: BEGIN OF it_bseg,
bukrs TYPE bukrs,
belnr TYPE belnr_d,
gjahr TYPE gjahr,
bschl TYPE bschl,
koart TYPE koart,
shkzg TYPE shkzg,
dmbtr TYPE dmbtr,
wrbtr TYPE wrbtr,
kostl TYPE kostl,
aufnr TYPE aufnr,
vbel2 TYPE vbeln_va,
posn2 TYPE posnr_va,
paobjnr TYPE rkeobjnr,
END OF it_bseg.
TYPES: BEGIN OF it_bkpf,
bukrs TYPE bukrs,
belnr TYPE belnr_d,
gjahr TYPE gjahr,
tcode TYPE tcode,
END OF it_bkpf.
TYPES: BEGIN OF it_bsis,
bukrs TYPE bukrs,
hkont TYPE hkont,
augdt TYPE augdt,
augbl TYPE augbl,
zuonr TYPE dzuonr,
gjahr TYPE gjahr,
belnr TYPE belnr_d,
buzei TYPE buzei,
waers TYPE waers,
shkzg TYPE shkzg,
END OF it_bsis.
TYPES: BEGIN OF it_ska1,
ktopl TYPE ktopl,
saknr TYPE saknr,
xbilk TYPE xbilk,
END OF it_ska1.
TYPES: BEGIN OF it_skb1,
bukrs TYPE bukrs,
saknr TYPE saknr,
END OF it_skb1.
********************************************
* Interne Tabelledefinition ohne Kopfzeile *
********************************************
CLASS-DATA: tab_bsis TYPE TABLE OF it_bsis INITIAL SIZE 0.
CLASS-DATA: tab_bkpf TYPE TABLE OF it_bkpf INITIAL SIZE 0.
CLASS-DATA: tab_bseg TYPE TABLE OF it_bseg INITIAL SIZE 0.
CLASS-DATA: tab_ska1 TYPE TABLE OF it_ska1 INITIAL SIZE 0.
CLASS-DATA: tab_skb1 TYPE TABLE OF it_skb1 INITIAL SIZE 0.
* CLASS-DATA: tab_output TYPE TABLE OF zerkonto.
ENDCLASS. "databasetrust DEFINITION
*----------------------------------------------------------------------*
* CLASS databasetrust IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS databasetrust IMPLEMENTATION.
METHOD selektion.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
SELECT ktopl saknr xbilk FROM ska1 INTO CORRESPONDING FIELDS OF TABLE tab_ska1
WHERE ktopl IN s_ktopl
AND saknr IN s_saknr
AND xbilk IN s_xbilk.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
SELECT bukrs saknr
FROM skb1 INTO CORRESPONDING FIELDS OF TABLE tab_skb1 FOR ALL ENTRIES IN tab_ska1
WHERE saknr = tab_ska1-saknr
AND bukrs IN s_bukrs.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
SELECT bukrs
hkont
augdt
augbl
zuonr
gjahr
belnr
buzei
waers
shkzg
FROM bsis INTO CORRESPONDING FIELDS OF TABLE tab_bsis FOR ALL ENTRIES IN tab_skb1
WHERE bukrs = tab_skb1-bukrs
AND hkont = tab_skb1-saknr
AND gjahr IN s_gjahr.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
SELECT bukrs
belnr
gjahr
tcode
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE tab_bkpf FOR ALL ENTRIES IN tab_bsis
WHERE bukrs = tab_bsis-bukrs AND belnr = tab_bsis-belnr AND gjahr = tab_bsis-gjahr.
***************************************
* Selektion Belegsegment Buchhaltung *
***************************************
SELECT bukrs
belnr
gjahr
bschl
koart
shkzg
dmbtr
wrbtr
kostl
aufnr
vbel2
posn2
paobjnr
FROM bseg INTO CORRESPONDING FIELDS OF TABLE tab_bseg FOR ALL ENTRIES IN tab_bkpf
WHERE bukrs = tab_bkpf-bukrs AND belnr = tab_bkpf-belnr AND gjahr = tab_bkpf-gjahr.
ENDMETHOD. "selektion
METHOD main.
FIELD-SYMBOLS: <tab_ska1> TYPE it_ska1,
<tab_skb1> TYPE it_skb1,
<tab_bsis> TYPE it_bsis,
<tab_bkpf> TYPE it_bkpf,
<tab_bseg> TYPE it_bseg.
DATA: itab_output TYPE zerkonto,
grid TYPE REF TO cl_gui_alv_grid.
LOOP AT tab_ska1 ASSIGNING <tab_ska1>.
LOOP AT tab_skb1 ASSIGNING <tab_skb1>
WHERE saknr = <tab_ska1>-saknr.
LOOP AT tab_bsis ASSIGNING <tab_bsis>
WHERE hkont = <tab_skb1>-saknr.
LOOP AT tab_bkpf ASSIGNING <tab_bkpf>
WHERE bukrs = <tab_bsis>-bukrs
AND belnr = <tab_bsis>-belnr
AND gjahr = <tab_bsis>-gjahr.
LOOP AT tab_bseg ASSIGNING <tab_bseg>
WHERE bukrs = <tab_bkpf>-bukrs
AND belnr = <tab_bkpf>-belnr
AND gjahr = <tab_bkpf>-gjahr.
"***********************************"
" Datenfüllen für ALV GRID "
"***********************************"
MOVE <tab_ska1>-ktopl TO itab_output-ktopl.
MOVE <tab_ska1>-saknr TO itab_output-saknr.
MOVE <tab_ska1>-xbilk TO itab_output-xbilk.
MOVE <tab_skb1>-bukrs TO itab_output-bukrs.
MOVE <tab_bsis>-gjahr TO itab_output-gjahr.
MOVE <tab_bsis>-belnr TO itab_output-belnr.
MOVE <tab_bseg>-bschl TO itab_output-bschl.
MOVE <tab_bseg>-koart TO itab_output-koart.
MOVE <tab_bseg>-shkzg TO itab_output-shkzg.
MOVE <tab_bseg>-dmbtr TO itab_output-dmbtr.
MOVE <tab_bseg>-wrbtr TO itab_output-wrbtr.
MOVE <tab_bseg>-kostl TO itab_output-kostl.
MOVE <tab_bseg>-aufnr TO itab_output-aufnr.
MOVE <tab_bseg>-vbel2 TO itab_output-vbel2.
MOVE <tab_bseg>-posn2 TO itab_output-posn2.
MOVE <tab_bseg>-paobjnr TO itab_output-paobjnr.
APPEND itab_output TO tab_output.
CLEAR: itab_output-bschl,
itab_output-koart,
itab_output-shkzg,
itab_output-dmbtr,
itab_output-wrbtr,
itab_output-kostl,
itab_output-aufnr,
itab_output-vbel2,
itab_output-posn2,
itab_output-paobjnr.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDMETHOD. "main
ENDCLASS. "databasetrust IMPLEMENTATION
START-OF-SELECTION.
databasetrust=>selektion( ).
databasetrust=>main( ).
break user912.
END-OF-SELECTION.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS '1000'.
* Titel zuweisen
SET TITLEBAR 'TITEL100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
* ALV Methode aufruf für Ausgabe
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'zerkonto'
CHANGING
it_outtab = tab_output.
ENDIF.
ENDMODULE. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "exit_program
Code: Alles auswählen.
http://www.pictureupload.de/pictures/200508133130_dynpro.jpg
Code: Alles auswählen.
databasetrust=>selektion( ).
databasetrust=>main( ).
Code: Alles auswählen.
SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME.
SELECT-OPTIONS: s_ktopl FOR ska1-ktopl,
s_saknr FOR ska1-saknr,
s_xbilk FOR ska1-xbilk,
s_bukrs FOR skb1-bukrs,
s_gjahr FOR bsis-gjahr.
SELECTION-SCREEN END OF BLOCK selection.
Code: Alles auswählen.
program zalvbseg.
tables: bseg,
zerkonto,
ska1,
skb1,
bsis,
bkpf.
data: g_custom_container type ref to cl_gui_custom_container,
g_container type scrfname value 'BCALV_GRID_CONTROL', "Dynproname
grid1 type ref to cl_gui_alv_grid, "ALV Grid Definition
ok_code like sy-ucomm, "Bildschirmbilder, Funktionscode, der PAI ausgelöst hat
tab_output type table of zerkonto.
selection-screen begin of block selection with frame.
select-options: s_ktopl for ska1-ktopl,
s_saknr for ska1-saknr,
s_xbilk for ska1-xbilk,
s_bukrs for skb1-bukrs,
s_gjahr for bsis-gjahr.
selection-screen end of block selection.
*----------------------------------------------------------------------*
* CLASS databasetrust DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class databasetrust definition.
public section.
class-methods selektion.
class-methods main.
private section.
***********************************
* TYPE Definition *
***********************************
types: begin of it_bseg,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
bschl type bschl,
koart type koart,
shkzg type shkzg,
dmbtr type dmbtr,
wrbtr type wrbtr,
kostl type kostl,
aufnr type aufnr,
vbel2 type vbeln_va,
posn2 type posnr_va,
paobjnr type rkeobjnr,
end of it_bseg.
types: begin of it_bkpf,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
tcode type tcode,
end of it_bkpf.
types: begin of it_bsis,
bukrs type bukrs,
hkont type hkont,
augdt type augdt,
augbl type augbl,
zuonr type dzuonr,
gjahr type gjahr,
belnr type belnr_d,
buzei type buzei,
waers type waers,
shkzg type shkzg,
end of it_bsis.
types: begin of it_ska1,
ktopl type ktopl,
saknr type saknr,
xbilk type xbilk,
end of it_ska1.
types: begin of it_skb1,
bukrs type bukrs,
saknr type saknr,
end of it_skb1.
********************************************
* Interne Tabelledefinition ohne Kopfzeile *
********************************************
class-data: tab_bsis type table of it_bsis initial size 0.
class-data: tab_bkpf type table of it_bkpf initial size 0.
class-data: tab_bseg type table of it_bseg initial size 0.
class-data: tab_ska1 type table of it_ska1 initial size 0.
class-data: tab_skb1 type table of it_skb1 initial size 0.
* CLASS-DATA: tab_output TYPE TABLE OF zerkonto.
endclass. "databasetrust DEFINITION
*----------------------------------------------------------------------*
* CLASS databasetrust IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class databasetrust implementation.
method selektion.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
select ktopl saknr xbilk from ska1 into corresponding fields of table tab_ska1
where ktopl in s_ktopl
and saknr in s_saknr
and xbilk in s_xbilk.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
select bukrs saknr
from skb1 into corresponding fields of table tab_skb1 for all entries in tab_ska1
where saknr = tab_ska1-saknr
and bukrs in s_bukrs.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
select bukrs
hkont
augdt
augbl
zuonr
gjahr
belnr
buzei
waers
shkzg
from bsis into corresponding fields of table tab_bsis for all entries in tab_skb1
where bukrs = tab_skb1-bukrs
and hkont = tab_skb1-saknr
and gjahr in s_gjahr.
***************************************
* Selektion Belegkopf für Buchhaltung *
***************************************
select bukrs
belnr
gjahr
tcode
from bkpf into corresponding fields of table tab_bkpf for all entries in tab_bsis
where bukrs = tab_bsis-bukrs and belnr = tab_bsis-belnr and gjahr = tab_bsis-gjahr.
***************************************
* Selektion Belegsegment Buchhaltung *
***************************************
select bukrs
belnr
gjahr
bschl
koart
shkzg
dmbtr
wrbtr
kostl
aufnr
vbel2
posn2
paobjnr
from bseg into corresponding fields of table tab_bseg for all entries in tab_bkpf
where bukrs = tab_bkpf-bukrs and belnr = tab_bkpf-belnr and gjahr = tab_bkpf-gjahr.
endmethod. "selektion
method main.
field-symbols: <tab_ska1> type it_ska1,
<tab_skb1> type it_skb1,
<tab_bsis> type it_bsis,
<tab_bkpf> type it_bkpf,
<tab_bseg> type it_bseg.
data: itab_output type zerkonto,
grid type ref to cl_gui_alv_grid.
loop at tab_ska1 assigning <tab_ska1>.
loop at tab_skb1 assigning <tab_skb1>
where saknr = <tab_ska1>-saknr.
loop at tab_bsis assigning <tab_bsis>
where hkont = <tab_skb1>-saknr.
loop at tab_bkpf assigning <tab_bkpf>
where bukrs = <tab_bsis>-bukrs
and belnr = <tab_bsis>-belnr
and gjahr = <tab_bsis>-gjahr.
loop at tab_bseg assigning <tab_bseg>
where bukrs = <tab_bkpf>-bukrs
and belnr = <tab_bkpf>-belnr
and gjahr = <tab_bkpf>-gjahr.
"***********************************"
" Datenfüllen für ALV GRID "
"***********************************"
move <tab_ska1>-ktopl to itab_output-ktopl.
move <tab_ska1>-saknr to itab_output-saknr.
move <tab_ska1>-xbilk to itab_output-xbilk.
move <tab_skb1>-bukrs to itab_output-bukrs.
move <tab_bsis>-gjahr to itab_output-gjahr.
move <tab_bsis>-belnr to itab_output-belnr.
move <tab_bseg>-bschl to itab_output-bschl.
move <tab_bseg>-koart to itab_output-koart.
move <tab_bseg>-shkzg to itab_output-shkzg.
move <tab_bseg>-dmbtr to itab_output-dmbtr.
move <tab_bseg>-wrbtr to itab_output-wrbtr.
move <tab_bseg>-kostl to itab_output-kostl.
move <tab_bseg>-aufnr to itab_output-aufnr.
move <tab_bseg>-vbel2 to itab_output-vbel2.
move <tab_bseg>-posn2 to itab_output-posn2.
move <tab_bseg>-paobjnr to itab_output-paobjnr.
append itab_output to tab_output.
clear: itab_output-bschl,
itab_output-koart,
itab_output-shkzg,
itab_output-dmbtr,
itab_output-wrbtr,
itab_output-kostl,
itab_output-aufnr,
itab_output-vbel2,
itab_output-posn2,
itab_output-paobjnr.
endloop.
endloop.
endloop.
endloop.
endloop.
endmethod. "main
endclass. "databasetrust IMPLEMENTATION
start-of-selection.
databasetrust=>selektion( ).
databasetrust=>main( ).
end-of-selection.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
module pbo output.
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
if g_custom_container is initial.
create object g_custom_container
exporting container_name = g_container.
create object grid1
exporting i_parent = g_custom_container.
call method grid1->set_table_for_first_display
exporting
i_structure_name = 'ZERKONTO'
changing
it_outtab = tab_output.
endif.
endmodule. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
module pai input.
* to react on oi_custom_events:
call method cl_gui_cfw=>dispatch.
case ok_code.
when 'EXIT'.
leave program.
when others.
* do nothing
endcase.
clear ok_code.
endmodule. "PAI INPUT
"EXIT_PROGRAM