2008 Mar 18 4:48 AM
Hi All,
I am using FM 'CURRENCY_AMOUNT_SAP_TO_DISPLAY' in my code. However after calling this FM in my program it is going to Dump & program is terminated.
I am getting ABAP runtime error BCD_FIELD_OVERFLOW.
and
Error analysis as
A value generated during processing is too large for
field "P_AMT_DISP" of program "Z_TEST_TEMP ".
Please tell me where I am wrong.....
Points would be rewarded...
Thanks
Jitendra.
Following is my code.
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
WAERK LIKE VBAK-WAERK,
CMPRE LIKE VBRP-CMPRE,
NETWR LIKE VBRP-NETWR,
END OF IT_OUTTAB.
PERFORM CURRENCY_DISPLAY USING
IT_OUTAB-WAERK
IT_OUTTAB-CMPRE
CHANGING
IT_OUTTAB-CMPRE.
PERFORM CURRENCY_DISPLAY USING
IT_OUTAB-WAERK
IT_OUTTAB-NETWR
CHANGING
IT_OUTTAB-NETWR.
&----
*& Form CURRENCY_DISPLAY
&----
text
----
-->P_IT_DATA_WAERK text
-->P_IT_DATA_CMPRE text
<--P_IT_OUTTAB_CMPRE text
----
FORM CURRENCY_DISPLAY USING P_CURRENCY
P_AMOUNT
CHANGING P_AMT_DISP.
DATA : P_CURRECNY TYPE TCURC-WAERS,
P_AMT TYPE WMTO_S-AMOUNT,
P_DISP TYPE WMTO_S-AMOUNT.
P_AMT = P_AMOUNT.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
EXPORTING
CURRENCY = P_CURRENCY
AMOUNT_INTERNAL = P_AMT
IMPORTING
AMOUNT_DISPLAY = P_DISP
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO WITH SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
P_AMT_DISP = P_DISP.
CLEAR : P_AMT, P_DISP.
ENDFORM. " CURRENCY_DISPLAY
2008 Mar 18 4:55 AM
hi,
do this way ...
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
WAERK LIKE VBAK-WAERK,
*CMPRE LIKE VBRP-CMPRE, """ ----> Comment it out
CMPRE(2) type p decimals 2,
*NETWR LIKE VBRP-NETWR, """ ----> Comment it out
NETWR(2) type p decimals 2,
END OF IT_OUTTAB.
2008 Mar 18 6:23 AM
Hi Santosh,
I did the changes according to u but still I am getting the dump and program is getting terminated.
I have pasetd my entire code in the thread..
2008 Mar 18 4:56 AM
Hi Jitendra Gujarathi ,
Check whether the "P_AMT_DISP" field has the data type "WMTO_S-AMOUNT" (DEC length 15 decimal 4)
Try out something like this
*Data : P_AMT_DISP LIKE WMTO_S-AMOUNT
Change the code as follows
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
WAERK LIKE VBAK-WAERK,
CMPRE LIKE VBRP-CMPRE,
NETWR LIKE VBRP-NETWR,
END OF IT_OUTTAB.
PERFORM CURRENCY_DISPLAY USING
IT_OUTAB-WAERK
IT_OUTTAB-CMPRE
CHANGING
IT_OUTTAB-CMPRE.
PERFORM CURRENCY_DISPLAY USING
IT_OUTAB-WAERK
IT_OUTTAB-NETWR
CHANGING
IT_OUTTAB-NETWR.
&----
*& Form CURRENCY_DISPLAY
&----
text
-
-->P_IT_DATA_WAERK text
-->P_IT_DATA_CMPRE text
<--P_IT_OUTTAB_CMPRE text
-
FORM CURRENCY_DISPLAY USING P_CURRENCY
P_AMOUNT
CHANGING P_AMT_DISP TYPE WMTO_S-AMOUNT.
DATA : P_CURRECNY TYPE TCURC-WAERS,
P_AMT TYPE WMTO_S-AMOUNT,
P_DISP TYPE WMTO_S-AMOUNT.
P_AMT = P_AMOUNT.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
EXPORTING
CURRENCY = P_CURRENCY
AMOUNT_INTERNAL = P_AMT
IMPORTING
AMOUNT_DISPLAY = P_DISP
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO WITH SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
P_AMT_DISP = P_DISP.
CLEAR : P_AMT, P_DISP.
ENDFORM. " CURRENCY_DISPLAY
Reward if useful
Cheers
Kripa Rangachari.
2008 Mar 18 5:03 AM
Hi Kripa,
I changed the code according to you but I got the syntax error ' IN Perform Currency_Display ' The actual Paramater "IT_OUTTAB-CMPRE" and Formal Parameter "P_AMT_DISp" are incompatable..
Thanks
Jitendra
2008 Mar 18 5:10 AM
The parameter should have the same data type as of the exporting parameter of the function module ...
can you post the entire code of your program "Z_TEST_TEMP"
Cheers
Kripa Rangachari.
2008 Mar 18 6:24 AM
Hi Kripa,
I have pasetd my entire code in the thread..
Please help me in this regards...
Its bit urgent...
2008 Mar 18 6:32 AM
As i said earlier, the data type should match for you to move the value.
So, you may try doing the following.
Before you call your "PERFORM CURRENCY_DISPLAY" you can convert the NETWR value to something say lv_netwr of data type WMTO_S-AMOUNT and then call the subroutine.
Hope this helps ...
reward if useful.
Cheers
Kripa Rangachari.
2008 Mar 18 7:06 AM
Hi,
I havedone the changes according to your guidance but now still the dump is comming and terminating the program.
Here is the Dump Summary....
ABAP runtime errors CONVT_OVERFLOW
Occurred on 18.03.2008 at 07:59:44
Overflow when converting from "3.73306e+12"
What happened?
The current ABAP/4 program "SAPLWMTO " had to be term
one of the statements could not be executed.
This is probably due to an error in the ABAP/4 program.
What can you do?
Note the actions and input that caused the error.
Inform your SAP system administrator.
You can print out this message by choosing "Print". T
allows you to display and manage termination messages
them beyond their normal deletion date.
Error analysis
When attempting to convert the value "3.73306e+12",
an overflow occurred.
This is the Dump Message....
The Corrected code is as below....
Global Var.
DATA : P_DISP TYPE WMTO_S-AMOUNT.
LOOP AT IT_DATA.
DATA : LV_NETWR LIKE WMTO_S-AMOUNT,
LV_CMPRE LIKE WMTO_S-AMOUNT.
CLEAR IT_OUTTAB.
MOVE-CORRESPONDING IT_DATA TO IT_OUTTAB.
FOR UNIT PRICE.
LV_CMPRE = IT_DATA-CMPRE.
PERFORM CURRENCY_DISPLAY USING IT_DATA-WAERK
LV_CMPRE.
LV_CMPRE = P_DISP.
IT_OUTTAB-CMPRE = LV_CMPRE.
CLEAR : P_DISP, LV_CMPRE.
FOR NET VALUE.
LV_NETWR = IT_DATA-NETWR.
PERFORM CURRENCY_DISPLAY USING IT_DATA-WAERK
LV_NETWR.
LV_NETWR = P_DISP.
IT_OUTTAB-NETWR = LV_NETWR.
CLEAR : P_DISP, LV_NETWR.
&----
*& Form CURRENCY_DISPLAY
&----
text
----
-->P_IT_DATA_WAERK text
-->P_IT_DATA_CMPRE text
<--P_IT_OUTTAB_CMPRE text
----
FORM CURRENCY_DISPLAY USING P_CURRENCY
P_AMOUNT.
*
DATA : P_CURRECNY TYPE TCURC-WAERS,
P_AMT TYPE WMTO_S-AMOUNT.
P_AMT = P_AMOUNT.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
EXPORTING
CURRENCY = P_CURRENCY
AMOUNT_INTERNAL = P_AMT
IMPORTING
AMOUNT_DISPLAY = P_DISP
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
P_AMT_DISP = P_DISP.
CLEAR : P_AMT, P_DISP.
ENDFORM. " CURRENCY_DISPLAY
2008 Mar 18 6:08 AM
Hi Kripa,
here is my entire code....
I am using this Currency FM to display the values according to the currency specified.
Eg Yen has no decimal places
Dollar euro have 2 decimals... and so on...
Can you tell me any other way by which I can
Display the data of unit and netprice accoring to currency type...
REPORT Z_TEST_TEMP
MESSAGE-ID Z64_I
NO STANDARD PAGE HEADING.
----
TYPE POOLS
----
TYPE-POOLS SLIS.
&----
TABLES
&----
TABLES: VBRK,
VBRP,
LIKP,
KNA1,
VBRL,
KNMT.
&----
INTERNAL TABLES
&----
DATA : BEGIN OF IT_JOIN OCCURS 0,
VBELN LIKE VBRK-VBELN,
FKART LIKE VBRK-FKART,
FKDAT LIKE VBRK-FKDAT,
VBELEN LIKE VBRL-VBELN,
POSNR LIKE VBRL-POSNR,
VBELN_VF LIKE VBRL-VBELN_VF,
END OF IT_JOIN.
DATA: BEGIN OF IT_DATA OCCURS 0,
VBELN LIKE VBRK-VBELN,
FKART LIKE VBRK-FKART,
FKDAT LIKE VBRK-FKDAT,
KUNAG LIKE VBRK-KUNAG,
KUNRG LIKE VBRK-KUNRG,
VKORG LIKE VBRK-VKORG,
VTWEG LIKE VBRK-VTWEG,
SPART LIKE VBRK-SPART,
WAERK LIKE VBRK-WAERK,
MATNR LIKE VBRP-MATNR,
ARKTX LIKE VBRP-ARKTX,
CHARG LIKE VBRP-CHARG,
FKIMG LIKE VBRP-FKIMG,
PSTYV LIKE VBRP-PSTYV,
CMPRE LIKE VBRP-CMPRE,
NETWR LIKE VBRP-NETWR,
VBELEN LIKE VBRP-VBELN,
POSNR LIKE VBRP-POSNR,
AUBEL LIKE VBRP-AUBEL,
AUPOS LIKE VBRP-AUPOS,
VGBEL LIKE VBRP-VGBEL,
VGPOS LIKE VBRP-VGPOS,
END OF IT_DATA.
DATA : BEGIN OF IT_LIKP OCCURS 0,
VBELN LIKE LIKP-VBELN,
LFDAT LIKE LIKP-LFDAT,
KUNNR LIKE LIKP-KUNNR,
WADAT_IST LIKE LIKP-WADAT_IST,
END OF IT_LIKP.
DATA : BEGIN OF IT_CUST_DATA OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME LIKE KNA1-NAME1,
END OF IT_CUST_DATA.
DATA : BEGIN OF IT_KNMT OCCURS 0,
VKORG LIKE KNMT-VKORG,
VTWEG LIKE KNMT-VTWEG,
KUNNR LIKE KNMT-KUNNR,
MATNR LIKE KNMT-MATNR,
POSTX LIKE KNMT-POSTX,
END OF IT_KNMT.
DATA : BEGIN OF IT_SAL_DTL OCCURS 0,
VBELN LIKE VBAK-VBELN,
BSTNK LIKE VBAK-BSTNK,
END OF IT_SAL_DTL.
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
VBELN LIKE VBRK-VBELN,
POSNR LIKE VBRP-POSNR,
FKART LIKE VBRK-FKART,
LFDAT LIKE LIKP-LFDAT,
KUNAG LIKE VBRK-KUNAG,
NAME LIKE KNA1-NAME1,
KUNNR LIKE LIKP-KUNNR,
NAME1 LIKE KNA1-NAME1,
MATNR LIKE VBRP-MATNR,
ARKTX LIKE VBRP-ARKTX,
POSTX LIKE KNMT-POSTX,
CHARG LIKE VBRP-CHARG,
FKIMG LIKE VBRP-FKIMG,
CMPRE LIKE VBRP-NETWR,"VBRP-CMPRE,
NETWR LIKE VBRP-NETWR,
INV_FKDAT LIKE VBRK-FKDAT,
FKDAT LIKE VBRK-FKDAT,
WADAT_IST LIKE LIKP-WADAT_IST,
VGBEL LIKE VBRP-VGBEL,
VGPOS LIKE VBRP-VGPOS,
AUBEL LIKE VBRP-AUBEL,
AUPOS LIKE VBRP-AUPOS,
BSTNK_VF LIKE VBRK-BSTNK_VF,
REMARK2(20) TYPE C, "LIKE TLINE-TDLINE,
KUNRG LIKE VBRK-KUNRG,
NAME2 LIKE KNA1-NAME1,
END OF IT_OUTTAB.
----
ALV List Variables
----
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, " FieldCat for Output
IT_EVENTS TYPE SLIS_T_EVENT, " ALV Events tab
GS_LAYOUT TYPE SLIS_LAYOUT_ALV, " ALV Layout
GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV, " Fieldcat
GS_EVENTS TYPE SLIS_ALV_EVENT. " ALV Events
----
VARIABLES
----
DATA: V_REPID LIKE SY-REPID.
&----
SELECTION SCREEN
&----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_BILL FOR VBRK-FKDAT,
S_SLD FOR VBRK-KUNAG,
S_SHP FOR LIKP-KUNNR,
S_PAYER FOR VBRK-KUNRG,
S_DIV FOR VBRK-SPART,
S_MATNR FOR VBRP-MATNR,
S_GI_DAT FOR LIKP-WADAT_IST.
SELECTION-SCREEN END OF BLOCK B1.
&----
AT SELECTION-SCREEN
&----
AT SELECTION-SCREEN.
PERFORM VALIDATE_SEL_SCREEN.
&----
START-OF-SELECTION
&----
START-OF-SELECTION.
*
PERFORM GET_DATA.
*
PERFORM FILL_OUTTAB.
&----
END-OF-SELECTION
&----
END-OF-SELECTION.
PERFORM DISPLAY_OUT_DATA.
&----
*& Form VALIDATE_SEL_SCREEN
&----
text
----
--> p1 text
<-- p2 text
----
FORM VALIDATE_SEL_SCREEN.
DATA: L_SLD_TO_PAR LIKE VBRK-KUNAG,
L_SHP_TO_PAR LIKE LIKP-KUNNR,
L_PAYER LIKE VBRK-KUNRG,
L_MATNR LIKE MARA-MATNR,
L_DIV LIKE VBAK-SPART.
*- Validate Division
IF NOT S_DIV[] IS INITIAL.
SELECT SINGLE SPART FROM TSPA
INTO L_DIV
WHERE SPART IN S_DIV.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Invalid Division'.
ENDIF.
ENDIF.
*- Validate Sold To Party
IF NOT S_SLD[] IS INITIAL.
SELECT SINGLE KUNNR FROM KNA1
INTO L_SLD_TO_PAR
WHERE KUNNR IN S_SLD.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Invalid Sold to Party'.
ENDIF.
ENDIF.
*- Validate Ship To Party
IF NOT S_SHP[] IS INITIAL.
SELECT SINGLE KUNNR FROM KNA1
INTO L_SHP_TO_PAR
WHERE KUNNR IN S_SHP.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Invalid Ship to Party'.
ENDIF.
ENDIF.
*- Validate Payer
IF NOT S_PAYER[] IS INITIAL.
SELECT SINGLE KUNNR FROM KNA1
INTO L_PAYER
WHERE KUNNR IN S_PAYER.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Invalid Payer'.
ENDIF.
ENDIF.
*- Validate Material Number
IF NOT S_MATNR[] IS INITIAL.
SELECT SINGLE MATNR FROM MARA
INTO L_MATNR
WHERE MATNR IN S_MATNR.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Invalid Material Number'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_SEL_SCREEN
&----
*& Form GET_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM GET_DATA.
WE GET ALL THE BILLING DOCUMENT NO. OF TYPE ZELR (INVOICE LIST) FROM
VBRK AND PASS THESE BILLING DOC NO. AS INVOICE LIST NO. TO VBRL AND
SELECT ALL THOSE BILLING DOCS UNDER THE CORRESPONDING INVOICE LIST NO.
DATA FROM VBRK & VBRL.
SELECT VBRKVBELN VBRKFKART VBRK~FKDAT
VBRLVBELN VBRLPOSNR VBRL~VBELN_VF FROM
VBRK INNER JOIN VBRL ON VBRKVBELN = VBRLVBELN
INTO TABLE IT_JOIN WHERE VBRK~FKDAT IN S_BILL
AND VBRK~FKART = 'ZELR'.
SORT IT_JOIN BY VBELN.
DATA FROM VBRK AND VBRP.
SELECT VBRKVBELN VBRKFKART VBRKFKDAT VBRKKUNAG VBRK~KUNRG "
VBRKVKORG VBRKVTWEG VBRKSPART VBRKWAERK
VBRPMATNR VBRPARKTX VBRPCHARG VBRPFKIMG
VBRPPSTYV VBRPCMPRE VBRPNETWR VBRPVBELN VBRP~POSNR
VBRPAUBEL VBRPAUPOS VBRPVGBEL VBRPVGPOS
INTO TABLE IT_DATA
FROM ( VBRK
INNER JOIN VBRP
ON VBRPVBELN = VBRKVBELN )
FOR ALL ENTRIES IN IT_JOIN
WHERE VBRK~VBELN = IT_JOIN-VBELN_VF
AND VBRK~KUNAG IN S_Sld
AND VBRK~KUNRG IN S_payer
AND VBRK~SPART IN S_Div
AND VBRP~MATNR IN S_MATNR.
SORT IT_DATA BY VBELN.
FOR DELIVERY DATE AND SHIP TO PARTY.
SELECT VBELN LFDAT KUNNR WADAT_IST FROM LIKP
INTO TABLE IT_LIKP
FOR ALL ENTRIES IN IT_DATA
WHERE VBELN = IT_DATA-VGBEL
AND KUNNR IN S_SHP
AND WADAT_IST IN S_GI_DAT.
SORT IT_LIKP BY VBELN.
FOR CUSTOMER MATERIAL DESCRIPTION.
SELECT VKORG VTWEG KUNNR MATNR POSTX
FROM KNMT INTO TABLE IT_KNMT
FOR ALL ENTRIES IN IT_DATA
WHERE MATNR = IT_DATA-MATNR
AND VKORG = IT_DATA-VKORG
AND VTWEG = IT_DATA-VTWEG.
GET CUSTOMER PO DATA FROM VBAK.
SELECT VBELN BSTNK FROM VBAK INTO TABLE IT_SAL_DTL
FOR ALL ENTRIES IN IT_DATA WHERE
VBELN = IT_DATA-AUBEL.
SORT IT_SAL_DTL BY VBELN.
GET CUSTOMER & CUSTOMER NAME FROM KNA1.
SELECT KUNNR NAME1 FROM KNA1 INTO TABLE IT_CUST_DATA.
SORT IT_CUST_DATA BY KUNNR.
ENDFORM. " GET_DATA
&----
*& Form FILL_OUTTAB
&----
text
----
--> p1 text
<-- p2 text
----
FORM FILL_OUTTAB.
LOOP AT IT_DATA.
Data : AMT_DISP LIKE WMTO_S-AMOUNT.
CLEAR : IT_OUTTAB.
MOVE-CORRESPONDING IT_DATA TO IT_OUTTAB.
FOR UNIT PRICE.
PERFORM CURRENCY_DISPLAY USING IT_DATA-WAERK
IT_DATA-CMPRE
CHANGING IT_OUTTAB-CMPRE.AMT_DISP
CHANGING AMT_DISP.
FOR NET VALUE.
PERFORM CURRENCY_DISPLAY USING IT_DATA-WAERK
IT_DATA-NETWR
CHANGING IT_OUTTAB-NETWR.
CHANGING AMT_DISP.
IT_OUTTAB-NETWR = AMT_Disp.
CLEAR AMT_Disp.
IF IT_DATA-PSTYV = 'ZREN' OR IT_DATA-PSTYV = 'ZG2N' OR
IT_DATA-PSTYV = 'G2N'.
IT_OUTTAB-CMPRE = IT_OUTTAB-CMPRE * -1.
IT_OUTTAB-NETWR = IT_OUTTAB-NETWR * -1.
ENDIF.
READ TABLE IT_JOIN WITH KEY VBELN_VF = IT_DATA-VBELN.
IT_OUTTAB-INV_FKDAT = IT_JOIN-FKDAT.
CLEAR IT_JOIN.
PERFORM READ_REMARKS USING IT_DATA-AUBEL IT_DATA-AUPOS
CHANGING IT_OUTTAB-REMARK2.
*
IF NOT IT_DATA-KUNAG IS INITIAL.
READ TABLE IT_CUST_DATA WITH KEY KUNNR = IT_OUTTAB-KUNAG.
IT_OUTTAB-NAME = IT_CUST_DATA-NAME.
CLEAR IT_CUST_DATA.
ENDIF.
*
IF NOT IT_DATA-KUNRG IS INITIAL.
READ TABLE IT_CUST_DATA WITH KEY KUNNR = IT_OUTTAB-KUNRG.
IT_OUTTAB-NAME2 = IT_CUST_DATA-NAME.
CLEAR IT_CUST_DATA.
ENDIF.
*
READ TABLE IT_LIKP WITH KEY VBELN = IT_DATA-VGBEL.
IF SY-SUBRC <> 0.
CONTINUE.
ELSE." KUNNR IN S_SHP.
IT_OUTTAB-LFDAT = IT_LIKP-LFDAT.
IT_OUTTAB-KUNNR = IT_LIKP-KUNNR.
IT_OUTTAB-WADAT_IST = IT_LIKP-WADAT_IST.
IF NOT IT_LIKP-KUNNR IS INITIAL.
READ TABLE IT_CUST_DATA WITH KEY KUNNR = IT_LIKP-KUNNR.
IT_OUTTAB-NAME1 = IT_CUST_DATA-NAME.
CLEAR IT_CUST_DATA.
ENDIF.
ENDIF.
*
READ TABLE IT_KNMT WITH KEY MATNR = IT_DATA-MATNR.
IT_OUTTAB-POSTX = IT_KNMT-POSTX.
*
READ TABLE IT_SAL_DTL WITH KEY VBELN = IT_DATA-AUBEL.
IT_OUTTAB-BSTNK_VF = IT_SAL_DTL-BSTNK.
*
APPEND IT_OUTTAB.
CLEAR : IT_OUTTAB, IT_DATA, IT_CUST_DATA, IT_KNMT, IT_LIKP, IT_SAL_DTL.
ENDLOOP.
ENDFORM. " FILL_OUTTAB
&----
*& Form DISPLAY_OUT_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY_OUT_DATA.
DATA : WS_VARIENT LIKE DISVARIANT.
WS_VARIENT-USERNAME = SY-UNAME.
WS_VARIENT-REPORT = SY-REPID.
PERFORM BUILD_FIELD_CAT.
*
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = SLIS_EV_PF_STATUS_SET
I_CALLBACK_USER_COMMAND = SLIS_EV_USER_COMMAND
IS_LAYOUT = P_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'U'
IS_VARIENT = WS_VARIENT
IT_EVENTS = P_EVENTS
TABLES
T_OUTTAB = IT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " DISPLAY_OUT_DATA
&----
*& Form BUILD_FIELD_CAT
&----
*
----
FORM BUILD_FIELD_CAT.
V_REPID = SY-CPROG.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_OUTTAB'
I_INCLNAME = V_REPID
CHANGING
CT_FIELDCAT = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ELSE.
LOOP AT IT_FIELDCAT INTO GS_FIELDCAT.
CASE GS_FIELDCAT-FIELDNAME.
WHEN 'VBELN'.
PERFORM BUILD_TEXT USING 'BILLING DOCUMENT'
CHANGING GS_FIELDCAT.
WHEN 'POSNR'.
PERFORM BUILD_TEXT USING 'BILL DOC ITEM'
CHANGING GS_FIELDCAT.
WHEN 'FKART'.
PERFORM BUILD_TEXT USING 'BILL DOC TYPE'
CHANGING GS_FIELDCAT.
WHEN 'LFDAT'.
PERFORM BUILD_TEXT USING 'DELIVERY DATE'
CHANGING GS_FIELDCAT.
WHEN 'KUNAG'.
PERFORM BUILD_TEXT USING 'SOLD-TO-PARTY'
CHANGING GS_FIELDCAT.
WHEN 'NAME'.
PERFORM BUILD_TEXT USING 'SLD-TO-PAR NAME'
CHANGING GS_FIELDCAT.
WHEN 'KUNNR'.
PERFORM BUILD_TEXT USING 'SHIP-TO-PARTY'
CHANGING GS_FIELDCAT.
WHEN 'NAME1'.
PERFORM BUILD_TEXT USING 'SHP-TO-PAR NAME'
CHANGING GS_FIELDCAT.
WHEN 'MATNR'.
PERFORM BUILD_TEXT USING 'MATERIAL'
CHANGING GS_FIELDCAT.
WHEN 'ARKTX'.
PERFORM BUILD_TEXT USING 'MATERIAL DESCRIPTION'
CHANGING GS_FIELDCAT.
WHEN 'POSTX'.
PERFORM BUILD_TEXT USING 'CUSTOMER MATERAL NAME'
CHANGING GS_FIELDCAT.
WHEN 'CHARG'.
PERFORM BUILD_TEXT USING 'BATCH'
CHANGING GS_FIELDCAT.
WHEN 'FKIMG'.
PERFORM BUILD_TEXT USING 'BILLED QUANTITY'
CHANGING GS_FIELDCAT.
WHEN 'CMPRE'.
PERFORM BUILD_TEXT USING 'UNIT PRICE'
CHANGING GS_FIELDCAT.
WHEN 'NETWR'.
PERFORM BUILD_TEXT USING 'TOTAL PRICE'
CHANGING GS_FIELDCAT.
WHEN 'INV_FKDAT'.
PERFORM BUILD_TEXT USING 'INVOICE BILL DATE'
CHANGING GS_FIELDCAT.
WHEN 'FKDAT'.
PERFORM BUILD_TEXT USING 'BILLING DATE'
CHANGING GS_FIELDCAT.
WHEN 'WADAT_IST'.
PERFORM BUILD_TEXT USING 'ACTUAL GI DATE'
CHANGING GS_FIELDCAT.
WHEN 'VGBEL'.
PERFORM BUILD_TEXT USING 'DELIVERY DOCUMENT'
CHANGING GS_FIELDCAT.
WHEN 'VGPOS'.
PERFORM BUILD_TEXT USING 'DEL DOC ITEM'
CHANGING GS_FIELDCAT.
WHEN 'AUBEL'.
PERFORM BUILD_TEXT USING 'SALES ORDER'
CHANGING GS_FIELDCAT.
WHEN 'AUPOS'.
PERFORM BUILD_TEXT USING 'SAL ORD ITEM'
CHANGING GS_FIELDCAT.
WHEN 'REMARK2'.
PERFORM BUILD_TEXT USING 'REMARK 2'
CHANGING GS_FIELDCAT.
WHEN 'BSTNK_VF'.
PERFORM BUILD_TEXT USING 'CUSTOMER PO ORDER NO.'
CHANGING GS_FIELDCAT.
WHEN 'KUNRG'.
PERFORM BUILD_TEXT USING 'PAYER'
CHANGING GS_FIELDCAT.
WHEN 'NAME2'.
PERFORM BUILD_TEXT USING 'PAYER NAME'
CHANGING GS_FIELDCAT.
ENDCASE.
MODIFY IT_FIELDCAT FROM GS_FIELDCAT.
ENDLOOP.
ENDIF. " OF SY-SUBRC.
ENDFORM. " BUILD_FIELD_CAT
*&----
*
*& Form BUILD_TEXT
*&----
*
Build the Text to be displayed in the Layout
----
FORM BUILD_TEXT USING P_I_TEXT
CHANGING P_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
P_FIELDCAT-seltext_l = P_I_TEXT.
P_FIELDCAT-ddictxt = 'L'.
ENDFORM. " BUILD_TEXT
&----
*& Form READ_REMARKS
&----
text
----
-->P_IT_DATA_AUBEL text
-->P_IT_DATA_AUPOS text
<--P_IT_OUTTAB_REMARK2 text
----
FORM READ_REMARKS USING P_IT_DATA_AUBEL
P_IT_DATA_AUPOS
CHANGING P_IT_OUTTAB_REMARK2.
CONSTANTS : LV_ID LIKE THEAD-TDID VALUE 'ZRM2',
LV_OBJECT LIKE THEAD-TDOBJECT VALUE 'VBBP',
LV_JA LIKE THEAD-TDSPRAS VALUE 'J',
LV_EN LIKE THEAD-TDSPRAS VALUE 'E'.
DATA : LV_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE,
LV_NAME LIKE THEAD-TDNAME.
CONCATENATE P_IT_DATA_AUBEL P_IT_DATA_AUPOS INTO LV_NAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = LV_ID
LANGUAGE = LV_EN
NAME = LV_NAME
OBJECT = LV_OBJECT
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = LV_LINES
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.
IF SY-SUBRC = 0.
READ TABLE LV_LINES INDEX 1.
IF SY-SUBRC = 0.
P_IT_OUTTAB_REMARK2 = LV_LINES-TDLINE.
ENDIF.
ELSE.
READ TEXT WITH LANGUAGE AS 'J'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = LV_ID
LANGUAGE = LV_JA
NAME = LV_NAME
OBJECT = LV_OBJECT
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = LV_LINES
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.
IF SY-SUBRC = 0.
READ TABLE LV_LINES INDEX 1.
IF SY-SUBRC = 0.
P_IT_OUTTAB_REMARK2 = LV_LINES-TDLINE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " READ_REMARKS
&----
*& Form CURRENCY_DISPLAY
&----
text
----
-->P_IT_DATA_WAERK text
-->P_IT_DATA_CMPRE text
<--P_IT_OUTTAB_CMPRE text
----
FORM CURRENCY_DISPLAY USING P_CURRENCY
P_AMOUNT
CHANGING P_AMT_DISP TYPE WMTO_S-AMOUNT..
DATA : P_CURRECNY TYPE TCURC-WAERS,
P_AMT TYPE WMTO_S-AMOUNT,
P_DISP TYPE WMTO_S-AMOUNT.
P_AMT = P_AMOUNT.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
EXPORTING
CURRENCY = P_CURRENCY
AMOUNT_INTERNAL = P_AMT
IMPORTING
AMOUNT_DISPLAY = P_DISP
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
P_AMT_DISP = P_DISP.
CLEAR : P_AMT, P_DISP.
ENDFORM. " CURRENCY_DISPLAY
2008 Mar 18 7:59 AM
As how santosh kumar sugests ... try doing this !
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
WAERK LIKE VBAK-WAERK,
*CMPRE LIKE VBRP-CMPRE, """ -
> Comment it out
CMPRE(2) type p decimals 2,
*NETWR LIKE VBRP-NETWR, """ -
> Comment it out
NETWR(2) type p decimals 2,
END OF IT_OUTTAB.