Code: Alles auswählen.
TABLES: mseg, mver, mkpf.
DATA: it_mseg LIKE STANDARD TABLE OF mseg,
wa_mseg LIKE LINE OF it_mseg.
DATA: it_mver LIKE STANDARD TABLE OF mver,
wa_mver LIKE LINE OF it_mver.
TYPES: BEGIN OF zeile_typ,
mblnr LIKE mkpf-mblnr,
bldat LIKE mkpf-bldat,
matnr LIKE mseg-matnr,
END OF zeile_typ.
TYPES it_mkpf_typ TYPE STANDARD TABLE OF zeile_typ.
DATA: it_mkpf TYPE it_mkpf_typ.
DATA: wa_mkpf TYPE zeile_typ.
SELECT-OPTIONS:
belart FOR mkpf-blart,
mblnr FOR mkpf-mblnr,
werk FOR mver-werks,
p_matnr FOR mver-matnr.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 ,
r2 RADIOBUTTON GROUP rad1 DEFAULT 'X' .
SELECTION-SCREEN END OF block b1.
*
*at SELECTION-SCREEN ON RADIOBUTTON GROUP rad1.
*
*BREAK-POINT.
* if r1 = 'X'.
*write:/' dschimix'.
* elseif r2 = 'X'.
* write:/ wa_mver-muv01, wa_mver-muv02, wa_mver-muv03, wa_mver-muv04, wa_mver-muv05, wa_mver-muv06, wa_mver-muv07,
* wa_mver-muv08, wa_mver-muv09, wa_mver-muv10, wa_mver-muv11, wa_mver-muv12.
* endif.
SELECT mkpf~mblnr mkpf~bldat mseg~matnr FROM mkpf
INNER JOIN mseg ON mkpf~mblnr = mseg~mblnr CLIENT specified INTO CORRESPONDING FIELDS OF TABLE it_mkpf
WHERE mkpf~mjahr > '2009' AND mseg~matnr IN p_matnr AND mseg~werks IN werk AND mseg~bwart = '601' AND mkpf~mblnr IN mblnr AND mkpf~blart IN belart.
"and blart in belart and mblnr in mblnr . "Alle Belegnummern mit Belegdatum die dem Mandant entsprechen
SELECT mver~muv01 mver~muv02 mver~muv03 mver~muv04 mver~muv05 mver~muv06 mver~muv07 mver~muv08 mver~muv09 mver~muv10 mver~muv11 mver~muv12
FROM mver INTO CORRESPONDING FIELDS OF TABLE it_mver WHERE matnr IN p_matnr AND werks IN werk
.
LOOP AT it_mkpf INTO wa_mkpf. " Aktuelle MBLNR
DATA: zunplnd LIKE mseg-menge.
DATA: zbelnr LIKE mseg-mblnr.
DATA: zbldat LIKE mkpf-bldat.
DATA: monat TYPE n LENGTH 2.
CLEAR: zunplnd, zbelnr, zbldat, monat.
ADD wa_mkpf-mblnr TO zbelnr. " Übergabe MBLNR
ADD wa_mkpf-bldat TO zbldat. " Übergabe Datum
DATA lv_menge TYPE menge.
SELECT SUM( menge ) FROM mseg INTO lv_menge
WHERE matnr = wa_mkpf-matnr AND werks = '2211' AND mblnr EQ zbelnr.
"mblnr EQ zbelnr and werks in werk and mseg~mjahr > '2009'. " and bwart = '601' and werks in werk.
"Zu verbuchende MENGE nach Bewegunsart und Belegnummer
DATA zeilen TYPE i.
DATA l_field TYPE char5. "l_field = Feldname
FIELD-SYMBOLS <l_field> TYPE ANY. " Zeiger
monat = zbldat+4(2). " Feld Monat erhält den Monat des Belegdatums
DATA lt_amveu TYPE TABLE OF mveu_ueb.
DATA ls_amveu TYPE mveu_ueb.
LOOP AT it_mver INTO wa_mver WHERE matnr = wa_mkpf-matnr.
CONCATENATE 'MUV' monat INTO l_field.
ASSIGN COMPONENT l_field OF STRUCTURE wa_mver TO <l_field>. "
ADD zunplnd TO <l_field>.
ls_amveu-matnr = wa_mver-matnr.
ls_amveu-werks = wa_mver-werks.
CONCATENATE zbldat(6) '01' INTO ls_amveu-ertag.
ls_amveu-kovbw = lv_menge. "[b]sind in einem Unicodeprogramm nicht ineinander konvertierbar???aber warum??[/b]
ls_amveu-kzexi = 'X'.
COLLECT ls_amveu INTO lt_amveu.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'MVER_MAINTAIN_DARK'
* EXPORTING
* SPERRMODUS = ' '
* MAX_ERRORS = 0
TABLES
* AMVEG_UEB =
amveu_ueb = lt_amveu
* AMERRDAT_F =
* EXCEPTIONS
* UPDATE_ERROR = 1
* INTERNAL_ERROR = 2
* TOO_MANY_ERRORS = 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.
Code: Alles auswählen.
DATA lv_menge TYPE menge.
Code: Alles auswählen.
DATA lv_menge TYPE mseg-menge.
Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
mknueppel
Code: Alles auswählen.
TABLES: mseg, mver, mkpf.
DATA: it_mseg LIKE STANDARD TABLE OF mseg,
wa_mseg LIKE LINE OF it_mseg.
DATA: it_mver LIKE STANDARD TABLE OF mver,
wa_mver LIKE LINE OF it_mver.
TYPES: BEGIN OF zeile_typ,
mblnr LIKE mkpf-mblnr,
bldat LIKE mkpf-bldat,
matnr LIKE mseg-matnr,
END OF zeile_typ.
TYPES it_mkpf_typ TYPE STANDARD TABLE OF zeile_typ.
DATA: it_mkpf TYPE it_mkpf_typ.
DATA: wa_mkpf TYPE zeile_typ.
SELECT-OPTIONS:
belart FOR mkpf-blart,
mblnr FOR mkpf-mblnr,
werk FOR mver-werks,
p_matnr FOR mver-matnr.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 ,
r2 RADIOBUTTON GROUP rad1 DEFAULT 'X' .
SELECTION-SCREEN END OF block b1.
at SELECTION-SCREEN ON RADIOBUTTON GROUP rad1.
BREAK-POINT.
if r1 = 'X'.
perform update_mver.
elseif r2 = 'X'.
write:/ wa_mver-muv01, wa_mver-muv02, wa_mver-muv03, wa_mver-muv04, wa_mver-muv05, wa_mver-muv06, wa_mver-muv07,
wa_mver-muv08, wa_mver-muv09, wa_mver-muv10, wa_mver-muv11, wa_mver-muv12.
endif.
SELECT mkpf~mblnr mkpf~bldat mseg~matnr FROM mkpf
INNER JOIN mseg ON mkpf~mblnr = mseg~mblnr CLIENT specified INTO CORRESPONDING FIELDS OF TABLE it_mkpf
WHERE mkpf~mjahr > '2009' AND mseg~matnr IN p_matnr AND mseg~werks IN werk AND mseg~bwart = '601' AND mkpf~mblnr IN mblnr AND mkpf~blart IN belart.
"and blart in belart and mblnr in mblnr . "Alle Belegnummern mit Belegdatum die dem Mandant entsprechen
*DESCRIBE TABLE it_mkpf.
SELECT mver~muv01 mver~muv02 mver~muv03 mver~muv04 mver~muv05 mver~muv06 mver~muv07 mver~muv08 mver~muv09 mver~muv10 mver~muv11 mver~muv12
FROM mver INTO CORRESPONDING FIELDS OF TABLE it_mver WHERE matnr IN p_matnr AND werks IN werk
.
LOOP AT it_mkpf INTO wa_mkpf. " Aktuelle MBLNR
DATA: zunplnd LIKE mseg-menge.
DATA: zbelnr LIKE mseg-mblnr.
DATA: zbldat LIKE mkpf-bldat.
DATA: monat TYPE n LENGTH 2.
CLEAR: zunplnd, zbelnr, zbldat, monat.
ADD wa_mkpf-mblnr TO zbelnr. " Übergabe MBLNR
ADD wa_mkpf-bldat TO zbldat. " Übergabe Datum
DATA lv_menge TYPE mseg-menge.
break-point.
SELECT SUM( menge ) FROM mseg INTO lv_menge
WHERE matnr = wa_mkpf-matnr AND werks = '2211' AND mblnr EQ zbelnr.
* SELECT mseg~menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_mseg
* WHERE matnr IN p_matnr AND werks = '2211' AND mblnr EQ zbelnr.
"mblnr EQ zbelnr and werks in werk and mseg~mjahr > '2009'. " and bwart = '601' and werks in werk.
"Zu verbuchende MENGE nach Bewegunsart und Belegnummer
* LOOP AT it_mseg INTO wa_mseg.
* ADD wa_mseg-menge TO zunplnd. SUM.
*
* ENDLOOP.
DATA zeilen TYPE i.
DATA l_field TYPE char5. "l_field = Feldname
FIELD-SYMBOLS <l_field> TYPE ANY. " Zeiger
monat = zbldat+4(2). " Feld Monat erhält den Monat des Belegdatums
DATA lt_amveu TYPE TABLE OF mveu_ueb.
DATA ls_amveu TYPE mveu_ueb.
LOOP AT it_mver INTO wa_mver WHERE matnr = wa_mkpf-matnr.
CONCATENATE 'MUV' monat INTO l_field.
ASSIGN COMPONENT l_field OF STRUCTURE wa_mver TO <l_field>. "
ADD zunplnd TO <l_field>.
*
ls_amveu-matnr = wa_mver-matnr.
ls_amveu-werks = wa_mver-werks.
CONCATENATE zbldat(6) '01' INTO ls_amveu-ertag.
ls_amveu-kovbw = lv_menge.
ls_amveu-kzexi = 'X'.
COLLECT ls_amveu INTO lt_amveu.
ENDLOOP.
ENDLOOP.
*WRITE:/ wa_mver-muv01, wa_mver-muv02, wa_mver-muv03, wa_mver-muv04, wa_mver-muv05, wa_mver-muv06, wa_mver-muv07,
* wa_mver-muv08, wa_mver-muv09, wa_mver-muv10, wa_mver-muv11, wa_mver-muv12.
form update_mver.
CALL FUNCTION 'MVER_MAINTAIN_DARK'
* EXPORTING
* SPERRMODUS = ' '
* MAX_ERRORS = 0
TABLES
* AMVEG_UEB =
amveu_ueb = lt_amveu.
* AMERRDAT_F =
* EXCEPTIONS
* UPDATE_ERROR = 1
* INTERNAL_ERROR = 2
* TOO_MANY_ERRORS = 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.
endform.
Code: Alles auswählen.
" Before
DATA lt_amveu TYPE TABLE OF mveu_ueb.
" After
DATA lt_amveu TYPE MGV_MVEU_UEB.
PERFORM update_mver USING lt_amveu.
FORM update_mver USING it_amveu TYPE MGV_MVEU_UEB.
CALL FUNCTION 'MVER_MAINTAIN_DARK'
TABLES
amveu_ueb = it_amveu. " use here the using parameter it_amveu
.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
Code: Alles auswählen.
TABLES: mseg, mver, mkpf.
DATA: it_mseg LIKE STANDARD TABLE OF mseg,
wa_mseg LIKE LINE OF it_mseg.
DATA: it_mver LIKE STANDARD TABLE OF mver,
wa_mver LIKE LINE OF it_mver.
TYPES: BEGIN OF zeile_typ,
mblnr LIKE mkpf-mblnr,
bldat LIKE mkpf-bldat,
matnr LIKE mseg-matnr,
END OF zeile_typ.
TYPES it_mkpf_typ TYPE STANDARD TABLE OF zeile_typ.
DATA: it_mkpf TYPE it_mkpf_typ.
DATA: wa_mkpf TYPE zeile_typ.
SELECT-OPTIONS:
belart FOR mkpf-blart,
mblnr FOR mkpf-mblnr,
werk FOR mver-werks,
p_matnr FOR mver-matnr.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 ,
r2 RADIOBUTTON GROUP rad1 DEFAULT 'X' .
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad1.
IF r1 = 'X'.
PERFORM update_mver.
ELSEIF r2 = 'X'.
perform write_data.
ENDIF.
SELECT mkpf~mblnr mkpf~bldat mseg~matnr FROM mkpf
INNER JOIN mseg ON mkpf~mblnr = mseg~mblnr CLIENT specified INTO CORRESPONDING FIELDS OF TABLE it_mkpf
WHERE mkpf~mjahr > '2009' AND mseg~matnr IN p_matnr AND mseg~werks IN werk AND mseg~bwart = '601' AND mkpf~mblnr IN mblnr AND mkpf~blart IN belart.
"and blart in belart and mblnr in mblnr . "Alle Belegnummern mit Belegdatum die dem Mandant entsprechen
*DESCRIBE TABLE it_mkpf.
SELECT mver~muv01 mver~muv02 mver~muv03 mver~muv04 mver~muv05 mver~muv06 mver~muv07 mver~muv08 mver~muv09 mver~muv10 mver~muv11 mver~muv12
FROM mver INTO CORRESPONDING FIELDS OF TABLE it_mver WHERE matnr IN p_matnr AND werks IN werk
.
form update_mver.
LOOP AT it_mkpf INTO wa_mkpf. " Aktuelle MBLNR
DATA: zunplnd LIKE mseg-menge.
DATA: zbelnr LIKE mseg-mblnr.
DATA: zbldat LIKE mkpf-bldat.
DATA: monat TYPE n LENGTH 2.
CLEAR: zunplnd, zbelnr, zbldat, monat.
ADD wa_mkpf-mblnr TO zbelnr. " Übergabe MBLNR
ADD wa_mkpf-bldat TO zbldat. " Übergabe Datum
DATA lv_menge TYPE mseg-menge.
BREAK-POINT.
SELECT SUM( menge ) FROM mseg INTO lv_menge
WHERE matnr = wa_mkpf-matnr AND werks = '2211' AND mblnr EQ zbelnr.
* SELECT mseg~menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_mseg
* WHERE matnr IN p_matnr AND werks = '2211' AND mblnr EQ zbelnr.
"mblnr EQ zbelnr and werks in werk and mseg~mjahr > '2009'. " and bwart = '601' and werks in werk.
"Zu verbuchende MENGE nach Bewegunsart und Belegnummer
* LOOP AT it_mseg INTO wa_mseg.
* ADD wa_mseg-menge TO zunplnd. SUM.
*
* ENDLOOP.
DATA zeilen TYPE i.
DATA l_field TYPE char5. "l_field = Feldname
FIELD-SYMBOLS <l_field> TYPE ANY. " Zeiger
monat = zbldat+4(2). " Feld Monat erhält den Monat des Belegdatums
DATA lt_amveu TYPE TABLE OF mveu_ueb.
DATA ls_amveu TYPE mveu_ueb.
LOOP AT it_mver INTO wa_mver WHERE matnr = wa_mkpf-matnr.
CONCATENATE 'MUV' monat INTO l_field.
ASSIGN COMPONENT l_field OF STRUCTURE wa_mver TO <l_field>. "
ADD zunplnd TO <l_field>.
*
ls_amveu-matnr = wa_mver-matnr.
ls_amveu-werks = wa_mver-werks.
CONCATENATE zbldat(6) '01' INTO ls_amveu-ertag.
ls_amveu-kovbw = lv_menge.
ls_amveu-kzexi = 'X'.
COLLECT ls_amveu INTO lt_amveu.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'MVER_MAINTAIN_DARK'
* EXPORTING
* SPERRMODUS = ' '
* MAX_ERRORS = 0
TABLES
* AMVEG_UEB =
amveu_ueb = lt_amveu.
* AMERRDAT_F =
* EXCEPTIONS
* UPDATE_ERROR = 1
* INTERNAL_ERROR = 2
* TOO_MANY_ERRORS = 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.
endform.
"update_mver
form write_data.
LOOP AT it_mkpf INTO wa_mkpf. " Aktuelle MBLNR
DATA: zunplnd LIKE mseg-menge.
DATA: zbelnr LIKE mseg-mblnr.
DATA: zbldat LIKE mkpf-bldat.
DATA: monat TYPE n LENGTH 2.
CLEAR: zunplnd, zbelnr, zbldat, monat.
ADD wa_mkpf-mblnr TO zbelnr. " Übergabe MBLNR
ADD wa_mkpf-bldat TO zbldat. " Übergabe Datum
DATA lv_menge TYPE mseg-menge.
BREAK-POINT.
SELECT SUM( menge ) FROM mseg INTO lv_menge
WHERE matnr = wa_mkpf-matnr AND werks = '2211' AND mblnr EQ zbelnr.
* SELECT mseg~menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_mseg
* WHERE matnr IN p_matnr AND werks = '2211' AND mblnr EQ zbelnr.
"mblnr EQ zbelnr and werks in werk and mseg~mjahr > '2009'. " and bwart = '601' and werks in werk.
"Zu verbuchende MENGE nach Bewegunsart und Belegnummer
* LOOP AT it_mseg INTO wa_mseg.
* ADD wa_mseg-menge TO zunplnd. SUM.
*
* ENDLOOP.
DATA zeilen TYPE i.
DATA l_field TYPE char5. "l_field = Feldname
FIELD-SYMBOLS <l_field> TYPE ANY. " Zeiger
monat = zbldat+4(2). " Feld Monat erhält den Monat des Belegdatums
DATA lt_amveu TYPE TABLE OF mveu_ueb.
DATA ls_amveu TYPE mveu_ueb.
LOOP AT it_mver INTO wa_mver WHERE matnr = wa_mkpf-matnr.
CONCATENATE 'MUV' monat INTO l_field.
ASSIGN COMPONENT l_field OF STRUCTURE wa_mver TO <l_field>. "
ADD zunplnd TO <l_field>.
*
ls_amveu-matnr = wa_mver-matnr.
ls_amveu-werks = wa_mver-werks.
CONCATENATE zbldat(6) '01' INTO ls_amveu-ertag.
ls_amveu-kovbw = lv_menge.
ls_amveu-kzexi = 'X'.
COLLECT ls_amveu INTO lt_amveu.
ENDLOOP.
ENDLOOP.
WRITE:/ wa_mver-muv01, wa_mver-muv02, wa_mver-muv03, wa_mver-muv04, wa_mver-muv05, wa_mver-muv06, wa_mver-muv07,
wa_mver-muv08, wa_mver-muv09, wa_mver-muv10, wa_mver-muv11, wa_mver-muv12.
endform.
Code: Alles auswählen.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 USER-COMMAND radio,
r2 RADIOBUTTON GROUP rad1 DEFAULT 'X' .
SELECTION-SCREEN END OF BLOCK b1.
Code: Alles auswählen.
TABLES: mseg, mver, mkpf.
DATA: it_mseg LIKE STANDARD TABLE OF mseg,
wa_mseg LIKE LINE OF it_mseg.
DATA: it_mver LIKE STANDARD TABLE OF mver,
wa_mver LIKE LINE OF it_mver.
TYPES: BEGIN OF zeile_typ,
mblnr LIKE mkpf-mblnr,
bldat LIKE mkpf-bldat,
matnr LIKE mseg-matnr,
END OF zeile_typ.
TYPES it_mkpf_typ TYPE STANDARD TABLE OF zeile_typ.
DATA: it_mkpf TYPE it_mkpf_typ.
DATA: wa_mkpf TYPE zeile_typ.
SELECT-OPTIONS:
belart FOR mkpf-blart,
mblnr FOR mkpf-mblnr,
werk FOR mver-werks,
p_matnr FOR mver-matnr.
SELECT mkpf~mblnr mkpf~bldat mseg~matnr FROM mkpf
INNER JOIN mseg ON mkpf~mblnr = mseg~mblnr INTO CORRESPONDING FIELDS OF TABLE it_mkpf
WHERE mkpf~mjahr > '2009' AND mseg~matnr IN p_matnr AND mseg~werks IN werk AND mseg~bwart = '601'
AND mkpf~mblnr IN mblnr AND mkpf~blart IN belart.
SELECT mver~muv01 mver~muv02 mver~muv03 mver~muv04 mver~muv05 mver~muv06 mver~muv07 mver~muv08 mver~muv09 mver~muv10 mver~muv11 mver~muv12
FROM mver INTO CORRESPONDING FIELDS OF TABLE it_mver WHERE matnr IN p_matnr AND werks IN werk.
LOOP AT it_mkpf INTO wa_mkpf. " Aktuelle MBLNR
DATA lv_menge TYPE mseg-menge.
DATA: zbelnr LIKE mseg-mblnr.
DATA: zbldat LIKE mkpf-bldat.
DATA: monat TYPE n LENGTH 2.
CLEAR: lv_menge, zbelnr, zbldat, monat.
ADD wa_mkpf-mblnr TO zbelnr. " Übergabe MBLNR
ADD wa_mkpf-bldat TO zbldat. " Übergabe Datum
SELECT SUM( menge ) FROM mseg INTO lv_menge
WHERE matnr = wa_mkpf-matnr AND werks = '2211' AND mblnr EQ zbelnr.
DATA l_field TYPE char5. "l_field = Feldname
FIELD-SYMBOLS <l_field> TYPE ANY. " Zeiger
monat = zbldat+4(2).
" Feld Monat erhält den Monat des Belegdatums
DATA lt_amveu TYPE TABLE OF mveu_ueb.
DATA ls_amveu TYPE mveu_ueb.
LOOP AT it_mver INTO wa_mver WHERE matnr = wa_mkpf-matnr.
CONCATENATE 'MUV' monat INTO l_field.
ASSIGN COMPONENT l_field OF STRUCTURE wa_mver TO <l_field>. "
ADD lv_menge TO <l_field>.
*
ls_amveu-matnr = wa_mver-matnr.
ls_amveu-werks = wa_mver-werks.
CONCATENATE zbldat(6) '01' INTO ls_amveu-ertag.
ls_amveu-kovbw = lv_menge.
ls_amveu-kzexi = 'X'.
COLLECT ls_amveu INTO lt_amveu.
ENDLOOP.
WRITE:/ wa_mver-muv01, wa_mver-muv02, wa_mver-muv03, wa_mver-muv04, wa_mver-muv05, wa_mver-muv06, wa_mver-muv07,
wa_mver-muv08, wa_mver-muv09, wa_mver-muv10, wa_mver-muv11, wa_mver-muv12.
ENDLOOP.
Code: Alles auswählen.
LOOP AT it_mver INTO wa_mver WHERE matnr = wa_mkpf-matnr.