Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a new Field to an existing report

Former Member
0 Kudos

Hi all,

Can anybody tell me, how to add an extra field in existing

report, without changing the basic calulation, which i made

in the same report.

Regards

Hema

4 REPLIES 4

madan_ullasa
Contributor
0 Kudos

Hi,

Your description is not sufficient to answert your question. What is the prob. in adding the new field? just make a data declaration and do it. if there is change in the basic calculation modify ur code..

you give a better description of ur issue..

regards,

Madan..

former_member125931
Active Participant
0 Kudos

Expalin your requirement clearly if it possible send code also and where you need to add the fiels then you will get proper answer.

Former Member
0 Kudos

Hi Hema,

your concern is not clear.

although i am providing solution. i hope it will helps you.

If you want to modify the original program you will need access key.You please contact your BASIS consultant for it.If you want to copy the original program and then to make changes to it then go to Tcode SE80.Give standard program name.Right click and copy the source program to taarget program

there are 3 ways for adding customfields to the standard program..

1.For any SAP standard program modification, you are required to login to OSS and request for a repair program Access key.

(OR)

2. use field exit enhancement.

(OR)

3. copy the original program into custom program then u can add ur own fields.

thanks

karthik

0 Kudos

okay... that is not a standard program.

sombody developed it.following is my existing code, here in last column i want to add BOM(mast-stlnr) and Component(stpo-idnrk). remaining things are okay.

REPORT ZPOTREND NO STANDARD PAGE HEADING

LINE-SIZE 195

LINE-COUNT 60(3)

MESSAGE-ID Z1.

TABLES: EKBE,

MARA,

TCURR.

SELECT-OPTIONS: S_GJAHR FOR EKBE-GJAHR,

S_BUDAT FOR EKBE-BUDAT DEFAULT SY-DATUM NO-EXTENSION,

S_MATNR FOR EKBE-MATNR,

S_WERKS FOR EKBE-WERKS DEFAULT 'CE',

S_MTART FOR MARA-MTART.

PARAMETERS: X_APP_L TYPE P DECIMALS 2 NO-DISPLAY,

X_APP_H TYPE P DECIMALS 2 NO-DISPLAY,

X_DTL AS CHECKBOX.

DATA: BEGIN OF I_EKBE OCCURS 0,

BUDAT LIKE EKBE-BUDAT,

MENGE LIKE EKBE-MENGE,

DMBTR LIKE EKBE-DMBTR,

SHKZG LIKE EKBE-SHKZG,

EBELN LIKE EKBE-EBELN,

MATNR LIKE EKBE-MATNR,

WERKS LIKE EKBE-WERKS,

MTART LIKE MARA-MTART,

MEINS LIKE MARA-MEINS,

END OF I_EKBE.

DATA: P_EBELN LIKE EKBE-EBELN,

P_MATNR LIKE EKBE-MATNR,

P_WERKS LIKE EKBE-WERKS,

P_MTART LIKE MARA-MTART,

P_MEINS LIKE MARA-MEINS.

DATA: BEGIN OF YMTH OCCURS 10,

YYMM(6),

MTH(3),

COL TYPE I,

MENGE LIKE EKBE-MENGE,

DMBTR LIKE EKBE-DMBTR,

END OF YMTH.

DATA: S_YMTH LIKE YMTH OCCURS 10 WITH HEADER LINE.

DATA: W_YMTH LIKE YMTH OCCURS 10 WITH HEADER LINE.

DATA: G_YMTH LIKE YMTH OCCURS 10 WITH HEADER LINE.

DATA: S_FLAG. "MTART FLAG

DATA: BEGIN OF CDATE,

YYMM(6),

DD(2) VALUE '01',

END OF CDATE.

DATA: SDATE LIKE SY-DATUM.

DATA: CMTH(6),

PMTH(6),

LMTH1(6),

LMTH2(6),

MTH(2).

DATA: W_MENGE LIKE EKBE-MENGE,

W_DMBTR LIKE EKBE-DMBTR,

W_MENGE1 LIKE EKBE-MENGE,

W_DMBTR1 LIKE EKBE-DMBTR,

W_TOTAL TYPE P DECIMALS 2,

W_COL TYPE I,

WTEXT(18),

APP TYPE P DECIMALS 4,

APP1 TYPE P DECIMALS 4,

APP2 TYPE P DECIMALS 4.

PERFORM GET_YMTH.

SELECT P~BUDAT P~MENGE P~DMBTR P~SHKZG P~EBELN P~MATNR P~WERKS

Q~MTART Q~MEINS

INTO TABLE I_EKBE

FROM EKBE AS P INNER JOIN MARA AS Q

ON P~MATNR = Q~MATNR

WHERE P~GJAHR IN S_GJAHR

AND P~BUDAT IN S_BUDAT

AND P~MATNR IN S_MATNR

AND P~WERKS IN S_WERKS

AND P~BEWTP = 'E'

AND Q~MTART IN S_MTART.

FORMAT INTENSIFIED OFF.

IF X_DTL <> 'X'.

LOOP AT I_EKBE.

I_EKBE-EBELN = SPACE.

MODIFY I_EKBE.

ENDLOOP.

ENDIF.

SORT I_EKBE BY WERKS MTART MATNR EBELN BUDAT.

LOOP AT I_EKBE.

CMTH = I_EKBE-BUDAT(6).

IF P_WERKS IS INITIAL.

P_WERKS = I_EKBE-WERKS.

P_MTART = I_EKBE-MTART.

P_MATNR = I_EKBE-MATNR.

P_EBELN = I_EKBE-EBELN.

P_MEINS = I_EKBE-MEINS.

PMTH = CMTH.

ENDIF.

IF P_WERKS NE I_EKBE-WERKS.

PERFORM CHG_MTH.

PERFORM CHG_MATNR.

PERFORM CHG_MTART.

PERFORM CHG_WERKS.

ENDIF.

IF P_MTART NE I_EKBE-MTART.

PERFORM CHG_MTH.

PERFORM CHG_MATNR.

PERFORM CHG_MTART.

ENDIF.

IF P_MATNR NE I_EKBE-MATNR.

PERFORM CHG_MTH.

PERFORM CHG_MATNR.

ENDIF.

IF P_EBELN NE I_EKBE-EBELN.

PERFORM CHG_MTH.

PERFORM CHG_MATNR.

ENDIF.

IF PMTH NE CMTH.

PERFORM CHG_MTH.

ENDIF.

IF I_EKBE-SHKZG = 'H'.

I_EKBE-MENGE = I_EKBE-MENGE * -1.

I_EKBE-DMBTR = I_EKBE-DMBTR * -1.

ENDIF.

IF I_EKBE-DMBTR NE 0.

W_MENGE = W_MENGE + I_EKBE-MENGE.

W_DMBTR = W_DMBTR + I_EKBE-DMBTR.

ENDIF.

ENDLOOP.

PERFORM CHG_MTH.

PERFORM CHG_MATNR.

PERFORM CHG_MTART.

PERFORM CHG_WERKS.

TOP-OF-PAGE.

WRITE:/ SY-DATUM,SY-UZEIT,

77 'A M T E K E N G I N E E R I N G L T D',

180 'Page', (4) SY-PAGNO.

WRITE: / SY-REPID,

77 ' Purchase Price Trending Report ',

180 SY-UNAME.

write: /78 'From Date', S_BUDAT-LOW, 'To Date', S_BUDAT-HIGH.

SKIP.

WRITE: / 'SBU :', I_EKBE-WERKS,

' Material Type :', I_EKBE-MTART.

SKIP.

READ TABLE YMTH WITH KEY YYMM = '999901'.

IF SY-SUBRC EQ 0.

WRITE AT YMTH-COL ' APP Change'.

ENDIF.

WRITE: /01 'Part No',

19 'PO No',

31 'Curr'.

LOOP AT YMTH.

YMTH-COL = YMTH-COL + 3.

IF YMTH-YYMM NE '999901'.

WRITE AT YMTH-COL YMTH-YYMM(4).

WRITE YMTH-MTH.

ELSE.

WRITE AT YMTH-COL ' %'.

ENDIF.

ENDLOOP.

ULINE.

&----


*& Form get_ymth

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_YMTH.

CMTH = S_BUDAT-HIGH(6).

PMTH = S_BUDAT-LOW(6).

IF S_BUDAT-HIGH IS INITIAL.

CMTH = PMTH.

ELSEIF S_BUDAT-LOW IS INITIAL.

PMTH = CMTH.

ENDIF.

LMTH1 = CMTH.

CDATE-YYMM = CMTH.

SDATE = CDATE.

SDATE = SDATE - 1.

LMTH2 = SDATE(6).

WHILE PMTH <= CMTH.

MTH = CMTH+4(2).

CDATE-YYMM = CMTH.

YMTH-YYMM = CMTH.

PERFORM GET_MTH.

APPEND YMTH.

SDATE = CDATE.

SDATE = SDATE - 1.

CMTH = sdate(6).

ENDWHILE.

YMTH-YYMM = '999901'.

YMTH-MTH = ' % '.

APPEND YMTH.

SORT YMTH BY YYMM.

W_COL = 21.

LOOP AT YMTH.

W_COL = W_COL + 15.

YMTH-COL = W_COL.

MODIFY YMTH.

ENDLOOP.

APPEND LINES OF YMTH TO S_YMTH.

APPEND LINES OF YMTH TO W_YMTH.

APPEND LINES OF YMTH TO G_YMTH.

REFRESH YMTH.

APPEND LINES OF S_YMTH TO YMTH.

ENDFORM. " get_ymth

&----


*& Form get_mth

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_MTH.

CASE MTH.

WHEN '01'.

YMTH-MTH = 'Jan'.

WHEN '02'.

YMTH-MTH = 'Feb'.

WHEN '03'.

YMTH-MTH = 'Mar'.

WHEN '04'.

YMTH-MTH = 'Apr'.

WHEN '05'.

YMTH-MTH = 'May'.

WHEN '06'.

YMTH-MTH = 'Jun'.

WHEN '07'.

YMTH-MTH = 'Jul'.

WHEN '08'.

YMTH-MTH = 'Aug'.

WHEN '09'.

YMTH-MTH = 'Sep'.

WHEN '10'.

YMTH-MTH = 'Oct'.

WHEN '11'.

YMTH-MTH = 'Nov'.

WHEN '12'.

YMTH-MTH = 'Dec'.

ENDCASE.

ENDFORM. " get_mth

&----


*& Form chg_matnr

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CHG_MATNR.

CLEAR W_TOTAL.

LOOP AT YMTH.

W_TOTAL = W_TOTAL + YMTH-DMBTR.

ENDLOOP.

IF W_TOTAL = 0.

EXIT.

ENDIF.

CLEAR: W_DMBTR, W_MENGE, W_DMBTR1, W_MENGE1, APP, APP1, APP2.

READ TABLE YMTH WITH KEY YYMM = LMTH2.

IF SY-SUBRC EQ 0 AND

YMTH-MENGE NE 0.

W_DMBTR = YMTH-DMBTR.

W_MENGE = YMTH-MENGE.

READ TABLE YMTH WITH KEY YYMM = LMTH1.

IF SY-SUBRC EQ 0.

APP = W_DMBTR / W_MENGE.

APP1 = YMTH-DMBTR / YMTH-MENGE.

APP2 = ( APP1 - APP ) / APP * 100.

ENDIF.

ENDIF.

IF X_APP_L IS INITIAL AND

X_APP_H IS INITIAL.

ELSE.

IF APP2 < X_APP_L OR

APP2 > X_APP_H.

EXIT.

CLEAR: W_DMBTR, W_MENGE, APP.

P_MATNR = I_EKBE-MATNR.

P_EBELN = I_EKBE-EBELN.

PERFORM CLR_YMTH.

ENDIF.

ENDIF.

SKIP.

  • WRITE:/ P_MATNR, ' Amount ',

  • 'USD'.

  • LOOP AT YMTH.

  • WRITE AT YMTH-COL(12) YMTH-DMBTR NO-ZERO.

  • ENDLOOP.

  • WRITE:/(18) ' ', ' Quantity',

  • P_MEINS.

  • LOOP AT YMTH.

  • WRITE AT YMTH-COL(12) YMTH-MENGE NO-ZERO.

  • ENDLOOP.

WRITE:/ P_MATNR(18), P_EBELN, 'USD' UNDER 'Curr'.

LOOP AT YMTH.

IF YMTH-YYMM NE '999901'.

CLEAR APP.

IF Ymth-menge ne 0.

APP = YMTH-DMBTR / YMTH-MENGE.

ENDIF.

WRITE AT YMTH-COL(12) APP.

READ TABLE S_YMTH WITH KEY YYMM = YMTH-YYMM.

IF SY-SUBRC EQ 0.

S_YMTH-MENGE = S_YMTH-MENGE + YMTH-MENGE.

S_YMTH-DMBTR = S_YMTH-DMBTR + YMTH-DMBTR.

MODIFY S_YMTH INDEX SY-TABIX.

ENDIF.

READ TABLE W_YMTH WITH KEY YYMM = YMTH-YYMM.

IF SY-SUBRC EQ 0.

W_YMTH-MENGE = W_YMTH-MENGE + YMTH-MENGE.

W_YMTH-DMBTR = W_YMTH-DMBTR + YMTH-DMBTR.

MODIFY W_YMTH INDEX SY-TABIX.

ENDIF.

ELSE.

WRITE AT YMTH-COL(12) APP2.

ENDIF.

ENDLOOP.

CLEAR: W_DMBTR, W_MENGE, APP.

P_MATNR = I_EKBE-MATNR.

P_EBELN = I_EKBE-EBELN.

PERFORM CLR_YMTH.

ENDFORM. " chg_matnr

&----


*& Form chg_mtart

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CHG_MTART.

SKIP.

ULINE.

CONCATENATE P_MTART 'Total' INTO WTEXT SEPARATED BY SPACE.

PERFORM PRN_TOT TABLES S_YMTH.

P_MTART = I_EKBE-MTART.

LOOP AT S_YMTH.

CLEAR: S_YMTH-DMBTR, S_YMTH-MENGE.

MODIFY S_YMTH.

ENDLOOP.

ENDFORM. " chg_mtart

&----


*& Form chg_werks

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CHG_WERKS.

CONCATENATE P_WERKS 'Total' INTO WTEXT SEPARATED BY SPACE.

PERFORM PRN_TOT TABLES W_YMTH.

CLEAR: W_DMBTR, W_MENGE, APP.

P_WERKS = I_EKBE-WERKS.

LOOP AT W_YMTH.

CLEAR: W_YMTH-DMBTR, W_YMTH-MENGE.

MODIFY W_YMTH.

ENDLOOP.

NEW-PAGE.

ENDFORM. " chg_werks

&----


&----


*& Form chg_mth

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CHG_MTH.

READ TABLE YMTH WITH KEY YYMM = PMTH.

IF SY-SUBRC EQ 0.

YMTH-MENGE = W_MENGE.

YMTH-DMBTR = W_DMBTR.

MODIFY YMTH INDEX SY-TABIX.

ENDIF.

CLEAR: W_MENGE, W_DMBTR.

PMTH = CMTH.

ENDFORM. " chg_mth

&----


*& Form clr_ymth

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CLR_YMTH.

LOOP AT YMTH.

CLEAR: YMTH-DMBTR, YMTH-MENGE.

MODIFY YMTH.

ENDLOOP.

ENDFORM. " clr_ymth

&----


*& Form prn_tot

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM PRN_TOT TABLES I_YMTH STRUCTURE YMTH.

CLEAR: W_DMBTR, W_MENGE, W_DMBTR1, W_MENGE1, APP, APP1, APP2.

READ TABLE I_YMTH WITH KEY YYMM = LMTH2.

IF SY-SUBRC EQ 0 AND

I_YMTH-MENGE NE 0.

W_DMBTR = I_YMTH-DMBTR.

W_MENGE = I_YMTH-MENGE.

READ TABLE I_YMTH WITH KEY YYMM = LMTH1.

IF SY-SUBRC EQ 0.

APP = W_DMBTR / W_MENGE.

APP1 = I_YMTH-DMBTR / I_YMTH-MENGE.

APP2 = ( APP1 - APP ) / APP * 100.

ENDIF.

ENDIF.

  • WRITE:/ WTEXT, ' Amount ',

  • 'USD'.

LOOP AT I_YMTH.

SELECT SINGLE * FROM TCURR

WHERE FCURR = 'SGD'

AND TCURR = 'USD'.

I_YMTH-DMBTR = I_YMTH-DMBTR * TCURR-UKURS.

  • WRITE AT I_YMTH-COL(12) I_YMTH-DMBTR NO-ZERO.

ENDLOOP.

  • WRITE:/(18) ' ', ' Quantity'.

  • LOOP AT I_YMTH.

  • WRITE AT I_YMTH-COL(12) I_YMTH-MENGE NO-ZERO.

  • ENDLOOP.

WRITE:/(18) ' ', ' APP ', 'USD'.

LOOP AT I_YMTH.

IF I_YMTH-YYMM NE '999901'.

CLEAR APP.

IF I_YMTH-MENGE NE 0.

APP = I_YMTH-DMBTR / I_YMTH-MENGE.

ENDIF.

WRITE AT I_YMTH-COL(12) APP.

ELSE.

WRITE AT I_YMTH-COL(12) APP2.

ENDIF.

ENDLOOP.

ULINE.

CLEAR: W_DMBTR, W_MENGE, APP.

ENDFORM. " prn_tot