cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Report

Former Member
0 Kudos

hi All,

in my report output the field of tax amount is ' BSEG-HWBAS ' it is coming as

' 1550.50- ' if i want the output to be ' -00001550.50 '.

how can i resolve this

thank you

himanshu sharma

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

call the function module CONVERSION_EXIT_ALPHA_INPUT..

Former Member
0 Kudos

hi,

I call that funcyion modules but the value are not getting converted .

thanks

himanshu

Former Member
0 Kudos

ok

u can do by Using Edit Masks

check the bold ones.

Edit masks enable you to:

  • Insert characters into the output

  • Move the sign to the beginning of a numeric field

  • Artificially insert or move a decimal point

  • Display a floating-point number without using scientific notation

Anywhere within an edit mask, the underscore character (_) has special meaning. At the beginning of an edit mask, V, LL, RR, and == have special meaning. All other characters are transferred without change to the output.

Underscores within an edit mask are replaced one-by-one with the characters from the source field (the field you are writing out). The number of characters taken from the source field will be equal to the number of underscores in the edit mask. For example, if there are three characters in the edit mask, at most three characters from the source field will be output. All other characters in the edit mask are inserted into the output. You also usually need to increase the length of the output field to accommodate the extra characters inserted by the mask.

For example, the statement write (6) 'ABCD' using edit mask '_:__:_' writes A:BC:D. Characters are taken from the source field one at a time, and characters from the edit mask are inserted at the points indicated by the mask. The statement write 'ABCD' using edit mask '_:__:_' only writes A:BC because the default output length is equal to the length of the source field (4).

If there are fewer underscores in the mask than there are in the source field, the default is to take the left-most n characters from the source field, where n equals the number of underscores in the edit mask. This can also be explicitly specified by preceding the edit mask with LL. For example, write 'ABCD' using edit mask 'LL__:_' takes the left-most three characters and writes out AB:C. Using RR instead takes the right-most three characters, so write 'ABCD' using edit mask 'RR__:_' will write out BC:D.

If there are more underscores than there are source field characters, the effect of LL is to left-justify the value in the output; RR right-justifies the value (see Listing 14.7 for an example).

<b>An edit mask beginning with a V, when applied to a numeric field (types i, p, and f), causes the sign field to be displayed at the beginning. If applied to a character field, a V is actually output.</b>

The Effect of Various Edit Masks

1 report ztx1407.

2 data: f1(4) value 'ABCD',

3 f2 type i value '1234-'.

4

5 write: / ' 5. ', f1,

6 / ' 6. ', (6) f1 using edit mask '_:__:_',

7 / ' 7. ', f1 using edit mask 'LL_:__',

8 / ' 8. ', f1 using edit mask 'RR_:__',

<b> 9 / ' 9. ', f2 using edit mask 'LLV______',</b>

10 / '10. ', f2 using edit mask 'RRV______',

11 / '11. ', f2 using edit mask 'RRV___,___',

12 / '12. ', f2 using edit mask 'LLV___,___',

13 / '13. ', f1 using edit mask 'V___'.

output:

5. ABCD

6. A:BC:D

7. A:BC

8. B:CD

<b>9. -1234 </b>

10. - 1234

11. - 1,234

12. -123,4

13. VABC

  • Line 5 outputs f1 without any edit masks.

  • Line 6 outputs all four characters of f1 using colons to separate them.

  • There are three underscores in the edit mask on line 7, but four characters in f1. Therefore, the first three characters of f1 are used in the edit mask.

  • Line 8 takes the last three characters of f1 and applies them to the edit mask.

  • There are six underscores in the edit mask on line 9, more than the four characters from f1. The value of f1 is output left-justified with a leading sign.

  • On line 10, the value of f1 is output right-justified with a leading sign.

  • Lines 11 and 12 show the effect of combining inserted characters with justification. The inserted characters do not move relative to the output field.

  • Line 13 shows the effect of using a V with a character field. The V itself is output.

<b>Using Conversion Exits</b>

A conversion exit is a called routine that formats the output. An edit mask that begins with == followed by a four-character ID calls a function module that formats the output. That four-character ID is known as a conversion exit, or conversion routine. The name of the function module will be CONVERSION_EXIT_XXXX_OUTPUT, where XXXX is the four-character id that follows ==. For example, write '00001000' using edit mask '==ALPHA' calls the function module CONVERSION_EXIT_ALPHA_OUTPUT. The write statement passes the value first to the function module, which changes it in any desired way and then returns the changed value, and that value is written out. This particular exit (ALPHA) examines the value to determine whether it consists entirely of numbers. If it does, leading zeros are stripped and the number is left-justified. Values containing non-numerics are not changed by ALPHA. SAP supplies about 60 conversion exits for various formatting tasks.

Conversion exits are particularly useful for complex formatting tasks that are needed in more than one program. To illustrate, the conversion exit CUNIT automatically converts the code representing a unit of measure into a description meaningful in the current logon language. For example, within R/3, the code for a crate of materials is KI. (KI is an abbreviation of kiste, the German word for "box.") However, CUNIT converts KI to the English mnemonic CR. Therefore, when logged on in English, write: '1', 'KI' using edit mask '==CUNIT'. writes 1 CR. For a user signed on in German, the output would be 1 KI. Using such a conversion exit enables a standard set of codes stored in the database to be automatically converted to be meaningful to the current logon language whenever output to a report.

Conversion Routines within a Domain

A conversion exit can also be placed into the Convers. Routine field in a domain. The exit is inherited by all fields that use that domain, and will be automatically applied when the value is written out.

Therefore, whenever ztxlfa1-lifnr is written, the value first passes through the function module CONVERSION_EXIT_ALPHA_OUTPUT, which strips leading zeros from numeric values.

A conversion exit within a domain can be turned off by specifying using no edit mask on the write statement.

1 report ztx1408.

2 tables: ztxlfa1, ztxmara.

3 data: f1(10) value '0000001000'.

4

5 write: / f1,

6 / f1 using edit mask '==ALPHA'.

7

8 skip.

9 select * from ztxlfa1 where lifnr = '00000010000'

10 or lifnr = 'V1'

11 order by lifnr.

12 write: / ztxlfa1-lifnr, "domain contains convers. exit ALPHA

13 / ztxlfa1-lifnr using no edit mask.

14 endselect.

15

16 skip.

17 select single * from ztxmara where matnr = 'M103'.

18 write: / ztxmara-matnr,

19 (10) ztxmara-brgew,

20 ztxmara-gewei. "domain contains convers. exit CUNIT

21 set locale language 'D'.

22 write: / ztxmara-matnr,

23 (10) ztxmara-brgew,

24 ztxmara-gewei. "domain contains convers. exit CUNIT

output:

0000001000

1000

1000

0000001000

V1

V1

M103 50.000 CR

M103 50.000 KI

  • Line 5 writes the value from f1.

  • Line 6 writes the same value but applies conversion exit ALPHA. Before being written, f1 is passed to the function module CONVERSION_EXIT_ALPHA_OUTPUT, which detects that the value is entirely numeric and strips off leading zeros and left-justifies it.

  • Line 9 retrieves two records from ztxlfa1and and writes the lifnr field twice for each.

  • The domain for ztxlfa1-lifnr contains the conversion exit ALPHA, so line 12 writes lifnr using that conversion exit.

  • Line 13 writes lifnr out, but turns off the conversion exit. This causes the actual value in the table to be written out.

  • Line 17 selects a single record from ztxmara.

  • Line 20 writes gewei (unit of weight) using conversion exit CUNIT in the domain.

  • Line 21 changes the text environment to German. This is equivalent to logging on in German.

  • Line 24 writes the same gewei value, but this time CUNIT displays the German mnemonic.

Displaying Existing Conversion Exits

To display the existing conversion exits, use the following procedure.

Start the ScreenCam "How to Display Existing Conversion Exits" now.

1. From the Development Workbench screen, choose the menu path Overview->Repository Infosys. The ABAP/4 Repository Information System screen is displayed.

2. Click on the plus beside Programming. The tree expands.

3. Click on the plus beside Function Library. The tree expands.

4. Double-click on the line Function Modules. The ABAP/4 Repository Information System: Function Module screen is displayed.

5. In the Function Module field, enter CONVERSION_EXIT_*_OUTPUT (the field is scrollable; you can enter more characters into it than it can display).

6. Press the Execute button on the Application toolbar. The Function Modules screen is displayed. All of the conversion exits that can be used on the write statement will be listed here.

i think it will useful for u.

Reward points if useful.

thanks,

Usha