Skip to Content
0
Former Member
Jul 31, 2006 at 06:30 AM

regarding report

26 Views

hi,

i want to display values of bkpf fields.after displaying i want to insert value for flag field.after insertig value of flag it will store in bkpf table.but i am doing report like below.but this is not updating the bkpf table.please let me know what is the reason.

-


*

REPORT ZFRI_UPDT_FLGINAD NO STANDARD PAGE HEADING

LINE-COUNT 60

LINE-SIZE 132.

TABLES: BKPF,BSEG.

*************************************************************************************

*structure for bkpf fields

*************************************************************************************

DATA: BEGIN OF IS_BKPF OCCURS 0,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

GJAHR LIKE BKPF-GJAHR,

BLART LIKE BKPF-BLART,

  • ZZSEND_FLG LIKE BKPF-ZZSEND_FLG,

ZZKEYERID LIKE BKPF-ZZKEYERID,

ZZCORRECTID LIKE BKPF-ZZCORRECTID,

ZZINTERCEPTID LIKE BKPF-ZZINTERCEPTID,

ZZAPPROVERID LIKE BKPF-ZZAPPROVERID,

END OF IS_BKPF.

*****************************************************************************************

*structure for bseg fields

*****************************************************************************************

DATA : BEGIN OF IS_BSEG OCCURS 0,

BUKRS LIKE BSEG-BUKRS,

BELNR LIKE BSEG-BELNR,

GJAHR LIKE BSEG-GJAHR,

BSCHL LIKE BSEG-BSCHL,

LIFNR LIKE BSEG-LIFNR,

END OF IS_BSEG.

****************************************************************************************

*final structure with bkpf,bseg fields

****************************************************************************************

DATA: BEGIN OF IS_FINAL OCCURS 0,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

GJAHR LIKE BKPF-GJAHR,

BLART LIKE BKPF-BLART,

ZZSEND_FLG LIKE BKPF-ZZSEND_FLG,

ZZKEYERID LIKE BKPF-ZZKEYERID,

ZZCORRECTID LIKE BKPF-ZZCORRECTID,

ZZINTERCEPTID LIKE BKPF-ZZINTERCEPTID,

ZZAPPROVERID LIKE BKPF-ZZAPPROVERID,

LIFNR LIKE BSEG-LIFNR,

END OF IS_FINAL.

***************************************************************************************

*internal tables from structures

***************************************************************************************

DATA: IT_BKPF LIKE TABLE OF IS_BKPF WITH HEADER LINE.

DATA: IT_BSEG LIKE TABLE OF IS_BSEG WITH HEADER LINE.

DATA: IT_FINAL LIKE TABLE OF IS_FINAL WITH HEADER LINE.

***************************************************************************************

*selection screen

****************************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME .

PARAMETERS:

P_BUKRS LIKE BKPF-BUKRS, "company code

P_BELNR LIKE BKPF-BELNR, "document number

P_GJAHR LIKE BKPF-GJAHR. "fiscal year

SELECTION-SCREEN END OF BLOCK BLK1.

********************************************************************************************

  • start of selection

*******************************************************************************************

START-OF-SELECTION.

SELECT BUKRS

BELNR

GJAHR

BLART

  • ZZSEND_FLG

*

ZZKEYERID

ZZCORRECTID

ZZINTERCEPTID

ZZAPPROVERID

INTO TABLE IT_BKPF

FROM BKPF

WHERE BUKRS EQ P_BUKRS AND

BELNR EQ P_BELNR AND

GJAHR EQ P_GJAHR.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

IF NOT IT_BKPF[] IS INITIAL.

SELECT BUKRS

BELNR

GJAHR

BSCHL

LIFNR

INTO TABLE IT_BSEG

FROM BSEG

FOR ALL ENTRIES IN IT_BKPF

WHERE BUKRS EQ IT_BKPF-BUKRS AND

BELNR EQ IT_BKPF-BELNR AND

GJAHR EQ IT_BKPF-GJAHR AND

BSCHL = '50'.

IF SY-SUBRC = 0.

SORT IT_BSEG BY BUKRS BELNR GJAHR.

ENDIF.

ENDIF.

LOOP AT IT_BKPF INTO IS_BKPF.

READ TABLE IT_BSEG WITH KEY BUKRS = IS_BKPF-BUKRS

BELNR = IS_BKPF-BELNR

GJAHR = IS_BKPF-GJAHR

BSCHL = '50'

binary search.

IF SY-SUBRC = 0.

MOVE : IS_BKPF-BUKRS TO IS_FINAL-BUKRS,

IS_BKPF-BELNR TO IS_FINAL-BELNR,

IS_BKPF-GJAHR TO IS_FINAL-GJAHR,

IS_BKPF-BLART TO IS_FINAL-BLART,

  • IS_BKPF-ZZSEND_FLG TO IS_FINAL-ZZSEND_FLG,

**

IS_BKPF-ZZKEYERID TO IS_FINAL-ZZKEYERID,

IS_BKPF-ZZCORRECTID TO IS_FINAL-ZZCORRECTID,

IS_BKPF-ZZINTERCEPTID TO IS_FINAL-ZZINTERCEPTID,

IS_BKPF-ZZAPPROVERID TO IS_FINAL-ZZAPPROVERID,

IS_BSEG-LIFNR TO IS_FINAL-LIFNR.

APPEND IS_FINAL TO IT_FINAL.

CLEAR:IS_FINAL,IT_FINAL.

ENDIF.

ENDLOOP.

*****************************************************************************************************

*end of selection

*****************************************************************************************************

END-OF-SELECTION.

LOOP AT IT_FINAL INTO IS_FINAL.

WRITE:/1(4) IS_FINAL-BUKRS,SY-VLINE,

11(10) IS_FINAL-BELNR, SY-VLINE,

25(4) IS_FINAL-GJAHR,SY-VLINE,

35(2) IS_FINAL-BLART,SY-VLINE.

WRITE:45(1) IS_FINAL-ZZSEND_FLG.

WRITE:53(4) IS_FINAL-ZZKEYERID,SY-VLINE,

57(4) IS_FINAL-ZZCORRECTID,SY-VLINE,

61(4) IS_FINAL-ZZINTERCEPTID,SY-VLINE,

65(4) IS_FINAL-ZZAPPROVERID,SY-VLINE,

69(4) IS_FINAL-LIFNR,SY-VLINE.

ENDLOOP.

  • **** ***********************************************************************************

  • *top of page

******************************************************************************************

TOP-OF-PAGE.

WRITE:/ SY-ULINE(110).

WRITE:/(10) 'COMPANYCODE', SY-VLINE,

(14) 'DOCUMENTNUMBER', SY-VLINE,

(10) 'FISCALYEAR', SY-VLINE,

(10) 'DOCUMENTTYPE' , SY-VLINE.

format input on.

WRITE:(8) 'SENDFLAG'.

FORMAT INPUT OFF.

WRITE:(4) 'KEYERID',SY-VLINE,

(4) 'CORRECTORID',SY-VLINE,

(4) 'INTERCEPTID',SY-VLINE,

(4) 'APPROVERID',SY-VLINE,

(4) 'VENDORNUMBER',SY-VLINE.

SET PF-STATUS 'TEST-STATUS'.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'SAVE'.

LOOP AT IT_FINAL WHERE ZZSEND_FLG <> ''.

UPDATE BKPF SET ZZSEND_FLG = IT_FINAL-ZZSEND_FLG

where BUKRS = IT_FINAL-BUKRS AND

BELNR = IT_FINAL-BELNR AND

GJAHR = IT_FINAL-GJAHR.

ENDLOOP.

WHEN 'CANCEL'.

LEAVE TO CURRENT TRANSACTION.

ENDCASE.