Showing posts with label Conversion Program. Show all posts
Showing posts with label Conversion Program. Show all posts

Friday, November 23, 2007

sap abap conversion Program to Test Line Selection & Scrolling within Document

BAP Questions:
I have generated a list containing say 20 lines, I need to display a checkbox on each line. Based on the user selection on the checkbox I need to capture the lines choosed by the user. How to do this?

*Program to Test Line Selection & Scrolling within Document:Rajiv
* Creating Text file of selected data
* carton selection
*-----------------------------------------------------------
REPORT ZRJ001
LINE-SIZE 120 LINE-COUNT 60 NO STANDARD PAGE HEADING.
*------------------------------------------------
* Defining Tables
*-----------------------------------------------
TABLES : ZPACK,ZTRN.

*------------------------------------------------
* Defining Internal Tables
*-----------------------------------------------
*DATA : IZPACK LIKE ZPACK OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF IZPACK OCCURS 0,
ZPKSLIP_NO LIKE ZPACK-ZPKSLIP_NO,
ZBATCH_NO LIKE ZPACK-ZBATCH_NO,
ZCARTON_NO LIKE ZPACK-ZCARTON_NO,
ZDATE LIKE ZPACK-ZDATE,
ZMATNR LIKE ZPACK-ZMATNR,
ZGROSS_WT LIKE ZPACK-ZGROSS_WT,
ZTARE_WT LIKE ZPACK-ZTARE_WT,
ZNET_WT LIKE ZPACK-ZNET_WT,
ZGRADE LIKE ZPACK-ZGRADE,
ZTRNTYP LIKE ZPACK-ZTRN_TYP,
END OF IZPACK.
*For Screen Command
DATA : BEGIN OF SCR1_OK_CODE OCCURS 0,
OK_CODE LIKE SY-UCOMM,
END OF SCR1_OK_CODE.

DATA : BEGIN OF SCR2_OK_CODE OCCURS 0,
OK_CODE LIKE SY-UCOMM,
END OF SCR2_OK_CODE.
*For Text file data
DATA : BEGIN OF ISEL OCCURS 0,
ZBATCH_NO LIKE ZPACK-ZBATCH_NO,
ZCARTON_NO LIKE ZPACK-ZCARTON_NO,
ZDATE LIKE ZPACK-ZDATE,
ZMATNR LIKE ZPACK-ZMATNR,
ZGROSS_WT LIKE ZPACK-ZGROSS_WT,
ZTARE_WT LIKE ZPACK-ZTARE_WT,
ZNET_WT LIKE ZPACK-ZNET_WT,
END OF ISEL.


*------------------------------------------------
* variables / constants
*-----------------------------------------------
DATA: MHD1 LIKE SY-TITLE,
MHD2 LIKE SY-TITLE,
MHD3 LIKE SY-TITLE,
CH(1) TYPE C VALUE '|',
CHK_BOX,
CHK_BOX_VAL,
LINE_NO LIKE SY-LINNO,
PAGE_NO LIKE SY-PAGNO,
SEL_CART TYPE I,
IZPACK_LINE TYPE I,
NEW_SCREEN,
SRNO TYPE I.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: ZSHIP_PT FOR ZPACK-ZSHIP_PT NO-EXTENSION NO INTERVALS
OBLIGATORY DEFAULT '5102'.
* ZMERGE FOR ZPACK-ZMERGE_NO. "Merge No.
SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN.
IF SY-UCOMM NE '1'. "Multiple Selection
IF ZSHIP_PT IS INITIAL.
MESSAGE E055(00).
ENDIF.
* IF ZMERGE IS INITIAL.
SELECT * FROM ZPACK INTO CORRESPONDING FIELDS OF TABLE IZPACK
WHERE ZSHIP_PT IN ZSHIP_PT.
* ELSE.
* SELECT * FROM ZPACK INTO CORRESPONDING FIELDS OF TABLE IZPACK
* WHERE ZSHIP_PT IN ZSHIP_PT AND ZMERGE_NO IN ZMERGE.
* ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E058(00) WITH ZSHIP_PT.
ENDIF.
ENDIF.
*At Line Selection
*-----------------
AT LINE-SELECTION.
PERFORM SELECT_CURRENT_LINE.

*Top of Page Operation
*---------------------
TOP-OF-PAGE.
MHD1 = 'WELSPUN SYNTEX LIMITED'.
MHD2 = 'Data Selection from Displayed Document.'.
MHD3 = 'Select Challan to Make selected List'.
PERFORM DATA_HEADER.
SET LEFT SCROLL-BOUNDARY COLUMN 15.

*User Command Choosen
*---------------------
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'LEFT'.
SCROLL LIST LEFT.
WHEN 'RIGH'.
SCROLL LIST RIGHT.
WHEN 'TOP'.
SCROLL LIST TO FIRST PAGE.
WHEN 'BOTT'.
SCROLL LIST TO LAST PAGE.
WHEN 'PREV'.
SCROLL LIST BACKWARD.
WHEN 'NEXT'.
SCROLL LIST FORWARD.
WHEN 'SELA'.
PERFORM SELECT_DESELECT_ALL USING 'X'.
WHEN 'SELD'.
PERFORM SELECT_DESELECT_ALL USING 'SPACE'.
WHEN 'SELC'.
PERFORM SELECT_CURRENT_LINE.
WHEN 'CONT'.
PERFORM GENERATE_INSPECTION_LIST USING 'X'.
WHEN 'LIST'.
PERFORM GENERATE_INSPECTION_LIST USING SPACE.
WHEN 'FILE'.
PERFORM GENERATE_INSPECTION_LIST USING 'Y'.
ENDCASE.

* SCROLL LIST TO PAGE pag.
* SCROLL LIST TO COLUMN col.

START-OF-SELECTION.
PERFORM LIST_OK_CODE.
SET PF-STATUS 'CARTLIST' EXCLUDING SCR2_OK_CODE.
PERFORM SELECT_DATA.
PERFORM LIST_DATA.

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*& Form LIST_OK_CODE
*&---------------------------------------------------------------------*
FORM LIST_OK_CODE. " Only for EXCLUDING OPTION
APPEND 'LIST' TO SCR1_OK_CODE.
APPEND 'SELA' TO SCR1_OK_CODE.
APPEND 'SELD' TO SCR1_OK_CODE.
APPEND 'SELC' TO SCR1_OK_CODE.
APPEND 'CONT' TO SCR1_OK_CODE.
APPEND 'FILE' TO SCR1_OK_CODE.
APPEND 'LEFT' TO SCR2_OK_CODE.
APPEND 'RIGH' TO SCR2_OK_CODE.
APPEND 'TOP' TO SCR2_OK_CODE.
APPEND 'BOTT' TO SCR2_OK_CODE.
APPEND 'PREV' TO SCR2_OK_CODE.
APPEND 'NEXT' TO SCR2_OK_CODE.
ENDFORM. " LIST_OK_CODE

*&---------------------------------------------------------------------*
*& Form SELECT_DATA
*&---------------------------------------------------------------------*
FORM SELECT_DATA.
*Data already selected when checking.
ENDFORM. " SELECT_DATA

*&---------------------------------------------------------------------*
*& Form LIST_DATA
*&---------------------------------------------------------------------*
FORM LIST_DATA.
SORT IZPACK BY ZPKSLIP_NO ZBATCH_NO.
LOOP AT IZPACK.
* AT NEW ZPKSLIP_NO.
* FORMAT COLOR 5 INVERSE.
* WRITE: /02 CHK_BOX AS CHECKBOX, 'Challan No :' COLOR 6
* INTENSIFIED, IZPACK-ZPKSLIP_NO hotspot on.
* FORMAT RESET.
* ENDAT.
FORMAT COLOR 1 INVERSE.
WRITE:/ CHK_BOX AS CHECKBOX.
WRITE: CH NO-GAP ,(13) IZPACK-ZCARTON_NO UNDER 'Carton No.' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZDATE UNDER 'Packing Date' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZGROSS_WT UNDER 'Gross Qty.' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZTARE_WT UNDER 'Tare Qty.' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZNET_WT UNDER 'Net Qty.' NO-GAP.
WRITE: CH NO-GAP ,(18) IZPACK-ZMATNR UNDER 'Material No.' NO-GAP.
WRITE: CH NO-GAP ,(12) IZPACK-ZBATCH_NO UNDER 'Lot No.' NO-GAP.
WRITE: CH NO-GAP ,(5) IZPACK-ZGRADE UNDER 'Grade' NO-GAP.
WRITE: CH NO-GAP ,(5) IZPACK-ZTRNTYP UNDER 'Type' NO-GAP.
WRITE: '|'.
FORMAT RESET.

ENDLOOP.
ENDFORM. " LIST_DATA

*&---------------------------------------------------------------------*
*& Form DATA_HEADER
*&---------------------------------------------------------------------*
FORM DATA_HEADER.
FORMAT COLOR COL_GROUP.
CALL FUNCTION 'Z_YHEAD_PRINT'
EXPORTING
TITLE1 = MHD1
TITLE2 = MHD2
TITLE3 = MHD3
COLOR = 'X'
EXCEPTIONS
OTHERS = 1.
FORMAT RESET.
FORMAT COLOR COL_HEADING.
WRITE :/02 'Carton No.',
17 'Packing Date',
30 'Gross Qty.',
45 'Tare Qty.',
60 'Net Qty.',
75 'Material No.',
95 'Lot No.',
105 'Grade',
112 'Type'.
ULINE.
FORMAT RESET.
ENDFORM. " DATA_HEADER

*&---------------------------------------------------------------------*
*& Form SELECT_CURRENT_LINE
*&---------------------------------------------------------------------*
FORM SELECT_CURRENT_LINE.
READ CURRENT LINE FIELD VALUE CHK_BOX INTO CHK_BOX_VAL.
IF CHK_BOX_VAL IS INITIAL.
CHK_BOX_VAL = 'X'.
ELSE.
CHK_BOX_VAL = SPACE.
ENDIF.
MODIFY CURRENT LINE FIELD VALUE CHK_BOX FROM CHK_BOX_VAL.

ENDFORM. " SELECT_CURRENT_LINE

*&---------------------------------------------------------------------*
*& Form SELECT_DESELECT_ALL
*&---------------------------------------------------------------------*
* -->P_0245 text
*----------------------------------------------------------------------*
*FORM SELECT_DESELECT_ALL USING VALUE(P_0245).
FORM SELECT_DESELECT_ALL USING P_VALUE.
LINE_NO = 8.
PAGE_NO = 1.
DO.
IF LINE_NO GT SY-LINCT.
LINE_NO = 8.
ADD 1 TO PAGE_NO.
ENDIF.
READ LINE LINE_NO OF PAGE PAGE_NO.
MODIFY LINE LINE_NO OF PAGE PAGE_NO
FIELD VALUE CHK_BOX FROM P_VALUE.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
ADD 1 TO LINE_NO.
ENDDO.

ENDFORM. " SELECT_DESELECT_ALL

*&---------------------------------------------------------------------*
*& Form GENERATE_INSPECTION_LIST
*&---------------------------------------------------------------------*
FORM GENERATE_INSPECTION_LIST USING P_CHECK.
LINE_NO = 8.
PAGE_NO = 1.
CLEAR:NEW_SCREEN,SRNO,SEL_CART.
DO.
IF LINE_NO GT SY-LINCT.
LINE_NO = 8.
ADD 1 TO PAGE_NO.
ENDIF.
READ LINE LINE_NO OF PAGE PAGE_NO FIELD
VALUE CHK_BOX INTO CHK_BOX_VAL.
IF SY-SUBRC EQ 0.
IF CHK_BOX_VAL = 'X'.
ADD 1 TO SEL_CART.
IF P_CHECK EQ ' '. " Only Checking
PERFORM CREATE_LIST.
ENDIF.
IF P_CHECK = 'Y'. "Replace data to table ISEL for text file
MOVE : IZPACK-ZBATCH_NO TO ISEL-ZBATCH_NO,
IZPACK-ZMATNR TO ISEL-ZMATNR,
IZPACK-ZCARTON_NO TO ISEL-ZCARTON_NO,
IZPACK-ZDATE TO ISEL-ZDATE,
IZPACK-ZGROSS_WT TO ISEL-ZGROSS_WT,
IZPACK-ZTARE_WT TO ISEL-ZTARE_WT,
IZPACK-ZNET_WT TO ISEL-ZNET_WT.
APPEND ISEL.
ENDIF.
ENDIF.
CHK_BOX_VAL = SPACE.
ELSE.
EXIT.
ENDIF.
ADD 1 TO LINE_NO.
ENDDO.
IF SEL_CART = 0.
MESSAGE S398(00) WITH 'Please Select the Carton first'.
ELSE.
MESSAGE S398(00) WITH SEL_CART 'Cartons were selected'.
IF P_CHECK = 'Y'.
PERFORM CREATE_FILE. "To Created Text file of Selected Cartons
ENDIF.
ENDIF.
ENDFORM. " GENERATE_INSPECTION_LIST

*&---------------------------------------------------------------------*
*& Form CREATE_LIST
*&---------------------------------------------------------------------*
FORM CREATE_LIST.
IF NEW_SCREEN IS INITIAL.
NEW_SCREEN = 'X'.
SET TITLEBAR 'INSP_LIST'.
SET PF-STATUS 'CARTLIST' EXCLUDING SCR1_OK_CODE.
MHD1 = 'WELSPUN SYNTEX LIMITED'.
MHD2 = 'ZPACK Data For Scroll Test.'.
MHD3 = 'List of Selected Cartons'.
PERFORM DATA_HEADER.
ENDIF.
IF SY-LINNO = 1.
* PERFORM HEADER2.
ENDIF.

IZPACK_LINE = LINE_NO - 7.
READ TABLE IZPACK INDEX IZPACK_LINE.
ADD 1 TO SRNO.
FORMAT COLOR 6 INVERSE.
WRITE:/ CH NO-GAP ,(13) IZPACK-ZCARTON_NO UNDER 'Carton No.' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZDATE UNDER 'Packing Date' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZGROSS_WT UNDER 'Gross Qty.' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZTARE_WT UNDER 'Tare Qty.' NO-GAP.
WRITE: CH NO-GAP ,(10) IZPACK-ZNET_WT UNDER 'Net Qty.' NO-GAP.
WRITE: CH NO-GAP ,(18) IZPACK-ZMATNR UNDER 'Material No.' NO-GAP.
WRITE: CH NO-GAP ,(12) IZPACK-ZBATCH_NO UNDER 'Lot No.' NO-GAP.
WRITE: CH NO-GAP ,(5) IZPACK-ZGRADE UNDER 'Grade' NO-GAP.
WRITE: CH NO-GAP ,(5) IZPACK-ZTRNTYP UNDER 'Type' NO-GAP.
WRITE: '|'.
WRITE:/ SY-ULINE(110).
FORMAT RESET.
*WRITE :/ SY-PFKEY.
ENDFORM. " CREATE_LIST

*&---------------------------------------------------------------------*
*& Form CREATE_FILE
*&---------------------------------------------------------------------*
FORM CREATE_FILE.
DATA: BEGIN OF ITAB_FIELDS OCCURS 0,
IFIELD_NAME(15) TYPE C,
END OF ITAB_FIELDS.

DATA: MNAME(4) TYPE C,
G_ROW TYPE I,
G_FILENAME LIKE RLGRAP-FILENAME. "Defining Filename.

LOOP AT ISEL.
G_ROW = G_ROW + 1.
ENDLOOP.
CONCATENATE 'C:\CHAL' SY-DATUM+6(2) SY-DATUM+4(2) '.DAT' INTO
G_FILENAME.
MESSAGE S899(MM) WITH 'Created file' G_FILENAME.
* APPEND FIELD NAME
MOVE G_ROW TO ITAB_FIELDS-IFIELD_NAME.
APPEND ITAB_FIELDS.
CLEAR ITAB_FIELDS.

* START DOWNLOAD
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = G_FILENAME
FILETYPE = 'DAT'
COL_SELECT = ' '
COL_SELECTMASK = ';'
TABLES
DATA_TAB = ISEL
FIELDNAMES = ITAB_FIELDS
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* END OF DOWNLOAD
MESSAGE S899(MM) WITH 'Created file' G_FILENAME.

ENDFORM. " CREATE_FILE

sap abap program for Split String into two parts at delimiter

*---------------------------------------------------------------------
* 29.04.2003 |Initial Author - | This program search for a delimiter
* |Amandeep Singh | and split it into two parts.
*---------------------------------------------------------------------
*
* Split String into two parts at delimeter
* Current delimeter is '/'.
*
REPORT ZSTRING.

DATA: LENGTH TYPE I,
REMAINING_LENGTH TYPE I ,
NEXT_POINTER TYPE I ,
FIRST_HALF(20) TYPE C ,
SECOND_HALF(20) TYPE C ,
TEMP TYPE I .


PARAMETER: WORD(35) TYPE C . "INPUT WORD

START-OF-SELECTION.

LENGTH = STRLEN( WORD ). "Length of the input String

SEARCH WORD FOR '/'.
IF SY-SUBRC = 0 .

IF SY-FDPOS > 0.
MOVE WORD+0(SY-FDPOS) TO FIRST_HALF.
ENDIF.
TEMP = SY-FDPOS + 1.

IF TEMP <> LENGTH.
NEXT_POINTER = SY-FDPOS + 1.
REMAINING_LENGTH = ( LENGTH - SY-FDPOS ) - 1.
MOVE WORD+NEXT_POINTER(REMAINING_LENGTH) TO SECOND_HALF.
ENDIF.

ENDIF.


WRITE:/'Input String:', WORD
.

WRITE:/'First Half:', FIRST_HALF.
WRITE:/'Second Half:', SECOND_HALF.

*-- End of Program


Additional add-on by Mike

Or you could just do:

split p0_source at con_tm into p0_left p0_right.
And if you have multiple splits then use a 1 field table as the target.

sap abap conversion Program For Printing Prime Number

*&---------------------------------------------------------------------*
*& Report ZPRIME *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT zprime .
DATA : t_no TYPE i,
res TYPE p,
pr_no TYPE p,
tag TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS : pr_num TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
pr_no = 1.
WHILE pr_no LE pr_num.
t_no = 2.
tag = 0.
WHILE t_no < pr_no.
res = pr_no MOD t_no.
IF res = 0.
WRITE : / pr_no.
WRITE : 'is not PRIME Number ' COLOR 3 INTENSIFIED OFF.
tag = 1.
EXIT.
ENDIF.
t_no = t_no + 1.
ENDWHILE.
IF tag = 0.
WRITE : / pr_no.
WRITE : 'is PRIME Number ' COLOR 6 INTENSIFIED OFF.
ENDIF.
pr_no = pr_no + 1.
ENDWHILE.

sap abap program for How can I get Ascii value of any letter

How can I get Ascii value of any letter. Is there any function?

This is how you do it :

report demtest.
data : c.
field-symbols : type x.
data : rn type i.
c = 'A'.
assign c to casting.
move to rn.
write rn.

This will convert 'A' to 65.

Tom Demuyt

How to convert ascii value to character.

If I give input as 65 (ascill value) I want display 'A'.

Below logic is for convert from character to ascii value , now I want to know how to convert ascii value to character.

Naveen

report demtest.

*going from A to 65

data : c value 'A'.
field-symbols : type x.
data : rn type i.
assign c to casting.
move to rn.
write rn.

*going from 66 to B

data : i type i value 66.
data : x type x.
field-symbols : type c.
move i to x.
assign x to casting type c.
move to c.
write c.

sap abap program for Figure to Words for India but can be modified to any requirement

* Test Program
Report ZJNC3.

Data: OffSet type I,
Amt2Words type String.


Selection-Screen: Begin of Block B1Opts with Frame Title TEXT-002.
Parameters: MyAmount type P Decimals 2 ,
MyChrsLn type I ,
MyNumLns type I .
Selection-Screen: End of Block B1Opts.


CALL FUNCTION 'ZAMT2WORDS'
EXPORTING
AMOUNT = MyAmount
CHRSLINE = MyChrsLn
NUMLINES = MyNumLns
CHANGING
AMT2WDS = Amt2Words.


Move 0 to OffSet.
Do MyNumLns Times.
Write: / Amt2Words+OffSet(MyChrsLn).
Add MyChrsLn to OffSet.
EndDo.

------------------------------------------------------------------------------------------
* Function Module ZAMT2WORDS

FUNCTION ZAMT2WORDS.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(AMOUNT) TYPE P
*" REFERENCE(CHRSLINE) TYPE I
*" REFERENCE(NUMLINES) TYPE I
*" CHANGING
*" REFERENCE(AMT2WDS) TYPE STRING
*"----------------------------------------------------------------------

* Nicely Cased words spelt corectly
* suits India
* takes care of singular & plural
* word wraps at line end
* ChrsLine = max no. of chars per line for wordwrapping.
* NumLines = max no. of lines

Data: chramount type String,
workStr type String,
numAmount type P Decimals 2.

Data: MyTwoDigits type I,
quotient type I,
remainder type I.

Data: cr type I,
lk type I,
th type I,
hun type I,
ten type I,
paisa type I.

Compute MAXLEN = ChrsLine * NumLines.

Move '' to mySpaces.
Do MAXLEN Times.
Concatenate mySpaces '.' into mySpaces.
EndDo.

Move ChrsLine to LineLength.

If LineLength <> 120.
Amt2Words = 'Invalid Parameters'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
Return.
EndIf.

If Amount = 0.
Amt2Words = 'Rupees Nil Only'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
Return.
EndIf.

* Reference is 'Seventeen'.

* Units & Teens
Words1 =
'One......' &
'Two......' &
'Three....' &
'Four.....' &
'Five.....' &
'Six......' &
'Seven....' &
'Eight....' &
'Nine.....' &
'Ten......' &
'Eleven...' &
'Twelve...' &
'Thirteen.' &
'Fourteen.' &
'Fifteen..' &
'Sixteen..' &
'Seventeen' &
'Eighteen.' &
'Nineteen.'.

Move '' to Words2.

* Tens
Words2 =
'Twenty...' &
'Thirty...' &
'Forty....' &
'Fifty....' &
'Sixty....' &
'Seventy..' &
'Eighty...' &
'Ninety...'.

If Amount < 0.
Amt2Words = 'Rupees Minus'.
Else.
Amt2Words = 'Rupees'.
EndIf.


* crlkthhtn.ps.
Compute numAmount = 1000000000 + Abs( Amount ).
Move numAmount to chramount.
Move chramount+1(2) to cr.
Move chramount+3(2) to lk.
Move chramount+5(2) to th.
Move chramount+7(1) to hun.
Move chramount+8(2) to ten.
Move chramount+11(2) to paisa.

If cr > 0.
Perform InWords2Digits Using cr.
If cr > 1.
Perform AppendWord Using 'Crores'.
Else.
Perform AppendWord Using 'Crore'.
EndIf.
EndIf.

If lk > 0.
Perform InWords2Digits Using lk.
If lk > 1.
Perform AppendWord Using 'Lakhs'.
Else.
Perform AppendWord Using 'Lakh'.
EndIf.
EndIf.

If th > 0.
Perform InWords2Digits Using th.
Perform AppendWord Using 'Thousand'.
EndIf.

If hun > 0.
Perform InWords2Digits Using hun.
Perform AppendWord Using 'Hundred'.
EndIf.

If ten > 0.
Perform InWords2Digits Using ten.
EndIf.

If paisa > 0.
If Amt2Words = 'Rupees'.
Amt2Words = 'Paisa'.
Else.
Perform AppendWord Using 'And'.
Perform AppendWord Using 'Paisa'.
EndIf.
Perform InWords2Digits Using paisa.
EndIf.

Perform AppendWord Using 'Only'.

Perform Rpad2MAX.

Amt2Wds = Amt2Words.

ENDFUNCTION.
------------------------------------------------------------------------------------------
* TOP level Include of Function Group ZUTIL

FUNCTION-POOL ZUTIL. "MESSAGE-ID ..

* Global ZUTIL Data
Data: Words1 type String,
Words2 type String,
Amt2Words type String,
mySpaces type String,
LineLength type I ,
MaxLen type I .

*&---------------------------------------------------------------------*
*& Form AppendWord
*&---------------------------------------------------------------------*
FORM AppendWord Using AddWord type String.

Data: NowLen type I,
AddLen type I,
NewLen type I,
DifLen type I,
workStr type String.

NowLen = StrLen( Amt2Words ).
NowLen = NowLen Mod LineLength.
AddLen = StrLen( AddWord ).

Compute NewLen = NowLen + 1 + AddLen.
If NewLen > LineLength.
DifLen = LineLength - NowLen.
If DifLen > 1.
Subtract 1 from DifLen.
Move mySpaces+0(DifLen) to workStr.
Concatenate Amt2Words workStr into Amt2Words.
EndIf.
EndIf.

* exact line boundary
If NowLen = 0.
Concatenate Amt2Words AddWord into Amt2Words.
Else.
Concatenate Amt2Words '.' AddWord into Amt2Words.
EndIf.

EndForm. " AppendWord

*&---------------------------------------------------------------------*
*& Form InWords2Digits
*&---------------------------------------------------------------------*
FORM InWords2Digits Using MyTwoDigits type I.
Data: quotient type I,
remainder type I,
workStr type String,
workIdx type I.

If MyTwoDigits > 19 .
Compute quotient = MyTwoDigits Div 10.
Compute remainder = MyTwoDigits Mod 10.

Compute workIdx = ( quotient - 2 ) * 9.
Move Words2+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.

If remainder > 0 .
Compute workIdx = ( remainder - 1 ) * 9.
Move Words1+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
EndIf.
Else.
Compute workIdx = ( MyTwoDigits - 1 ) * 9.
Move Words1+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
EndIf.

EndForm. " InWords2Digits

*&---------------------------------------------------------------------*
*& Form Rpad2MAX
*&---------------------------------------------------------------------*
FORM Rpad2MAX.
Concatenate Amt2Words mySpaces into Amt2Words.
Move Amt2Words+0(MAXLEN) to Amt2Words.
Concatenate Amt2Words '*' into Amt2Words.
Replace All Occurrences Of '.' in Amt2Words With ' !'.
Replace All Occurrences Of '!' in Amt2Words With ' '.
EndForm. " Rpad2MAX
-------------------------------------------------------

sap abap conversion program for Print Number Value Without Thousand Separator

How can I print number value without thousand separator?

See Eg.
data mqty type p decimals 3 value '1234.45'.
write:/ mqty .

Result is : 1,234.45
And I want to print it like 1234.45

I usually using the REPLACE Command,

mqty = '1,234.45'.

REPLACE ',' WITH '' INTO mqty.

Or

REPLACE ',' WITH SPACE INTO mqty.

ABAP Tips by: Nurmansah

For thousand separator, you should write this program.

You can also write this program as function. You can call when it require.
ex:

DATA : x TYPE i,
chspec(10).

MOVE it_comm1-fobval TO chspec.
CONDENSE chspec.
x = STRLEN( chspec ) .

IF x LE 3.
chspec = ''.
ELSEIF x = 4.
chspec = '_,___'.
ELSEIF x = 5.
chspec = '__,___'.
ELSEIF x = 6.
chspec = '_,__,___'.
ELSEIF x = 7.
chspec = '_,__,___'.
ENDIF.

WRITE: 89(12) it_comm1-fobval RIGHT-JUSTIFIED USING EDIT MASK chspec.

it_comm1-fobval = '1234'
result
1,234

sap abap conversion program for Insert a special Tab Delimited Character

REPORT Z_DELIMIT_DOWNLOAD.

* Inserting a Tab Delimited between the Fields in the Internal Table
*
* This program allows you to insert any Tab Delimited characters easily.
*
* You have to create the customized Function in SE37 First.
*
* The customized functions will replace all the fields in your internal table
* with your desired Tab Delimited characters.
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
* http://www.sap-img.com
*
*
*Replace DELIMIT with "," in the function

DATA: BEGIN OF ITAB OCCURS 100,
TXT01(10),
TXT02(10),
END OF ITAB.

SELECTION-SCREEN BEGIN OF BLOCK FILE_OP WITH FRAME TITLE TEXT-030.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: DLOAD AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN COMMENT 4(30) TEXT-027.
PARAMETERS: FILE LIKE RLGRAP-FILENAME
DEFAULT 'C:\TEMP\ZTEST.TXT'.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK FILE_OP.

ITAB-TXT01 = 'TEXT01'.
ITAB-TXT02 = 'TEXT01'.
APPEND ITAB.

ITAB-TXT01 = 'TEXT02'.
ITAB-TXT02 = 'TEXT02'.
APPEND ITAB.

PERFORM DOWNLOAD.
*---------------------------------------------------------------------*
* FORM DOWNLOAD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM DOWNLOAD.

DATA: BEGIN OF DUMP OCCURS 0,
C(2048) TYPE C,
END OF DUMP.

REFRESH DUMP.
CALL FUNCTION 'Z_DELIMIT_DOWNLOAD'
EXPORTING
DELIMIT = ','
TABLES
INTAB = ITAB
OUTTAB = DUMP
EXCEPTIONS
CONVERSION_FAILED = 01.

LOOP AT DUMP.
WRITE:/ DUMP.
ENDLOOP.

CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'DAT'
MODE = ' '
TABLES
DATA_TAB = DUMP
EXCEPTIONS
FILE_OPEN_ERROR = 01
FILE_WRITE_ERROR = 02
INVALID_FILESIZE = 03
INVALID_TABLE_WIDTH = 04
INVALID_TYPE = 05
NO_BATCH = 06
UNKNOWN_ERROR = 07.
ENDFORM.

*************************************************
* This Function modules need to be created first.
*************************************************
FUNCTION Z_DELIMIT_DOWNLOAD .
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(DELIMIT)
*" TABLES
*" INTAB
*" OUTTAB
*"----------------------------------------------------------------------


FIELD-SYMBOLS: .

DATA: LEN TYPE I,
NUM TYPE I,
DELIMIT_LEN TYPE I.

DELIMIT_LEN = STRLEN( DELIMIT ).

LOOP AT INTAB.
CLEAR OUTTAB.
NUM = 0.
DO.
* Get name of next structure field into
ASSIGN COMPONENT SY-INDEX OF STRUCTURE INTAB TO .
IF SY-SUBRC <> 0. EXIT. ENDIF. " No more fields in structure

LEN = STRLEN( ).
WRITE: TO OUTTAB+NUM(LEN). " Write field to output table
NUM = NUM + LEN.

WRITE: DELIMIT TO OUTTAB+NUM(DELIMIT_LEN).
NUM = NUM + DELIMIT_LEN.
ENDDO.
APPEND OUTTAB.
ENDLOOP.
ENDFUNCTION.

sap abap program for Split String into two parts at delimiter

*---------------------------------------------------------------------
* 29.04.2003 |Initial Author - | This program search for a delimiter
* |Amandeep Singh | and split it into two parts.
*---------------------------------------------------------------------
*
* Split String into two parts at delimeter
* Current delimeter is '/'.
*
REPORT ZSTRING.

DATA: LENGTH TYPE I,
REMAINING_LENGTH TYPE I ,
NEXT_POINTER TYPE I ,
FIRST_HALF(20) TYPE C ,
SECOND_HALF(20) TYPE C ,
TEMP TYPE I .


PARAMETER: WORD(35) TYPE C . "INPUT WORD

START-OF-SELECTION.

LENGTH = STRLEN( WORD ). "Length of the input String

SEARCH WORD FOR '/'.
IF SY-SUBRC = 0 .

IF SY-FDPOS > 0.
MOVE WORD+0(SY-FDPOS) TO FIRST_HALF.
ENDIF.
TEMP = SY-FDPOS + 1.

IF TEMP <> LENGTH.
NEXT_POINTER = SY-FDPOS + 1.
REMAINING_LENGTH = ( LENGTH - SY-FDPOS ) - 1.
MOVE WORD+NEXT_POINTER(REMAINING_LENGTH) TO SECOND_HALF.
ENDIF.

ENDIF.


WRITE:/'Input String:', WORD
.

WRITE:/'First Half:', FIRST_HALF.
WRITE:/'Second Half:', SECOND_HALF.

*-- End of Program


Additional add-on by Mike

Or you could just do:

split p0_source at con_tm into p0_left p0_right.
And if you have multiple splits then use a 1 field table as the target.

sap abap conversion Program For Printing Prime Number

*&---------------------------------------------------------------------*
*& Report ZPRIME *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT zprime .
DATA : t_no TYPE i,
res TYPE p,
pr_no TYPE p,
tag TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS : pr_num TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
pr_no = 1.
WHILE pr_no LE pr_num.
t_no = 2.
tag = 0.
WHILE t_no < pr_no.
res = pr_no MOD t_no.
IF res = 0.
WRITE : / pr_no.
WRITE : 'is not PRIME Number ' COLOR 3 INTENSIFIED OFF.
tag = 1.
EXIT.
ENDIF.
t_no = t_no + 1.
ENDWHILE.
IF tag = 0.
WRITE : / pr_no.
WRITE : 'is PRIME Number ' COLOR 6 INTENSIFIED OFF.
ENDIF.
pr_no = pr_no + 1.
ENDWHILE.

sap abap program for How can I get Ascii value of any lettergot

How can I get Ascii value of any letter. Is there any function?

This is how you do it :

report demtest.
data : c.
field-symbols : type x.
data : rn type i.
c = 'A'.
assign c to casting.
move to rn.
write rn.

This will convert 'A' to 65.

Tom Demuyt

How to convert ascii value to character.

If I give input as 65 (ascill value) I want display 'A'.

Below logic is for convert from character to ascii value , now I want to know how to convert ascii value to character.

Naveen

report demtest.

*going from A to 65

data : c value 'A'.
field-symbols : type x.
data : rn type i.
assign c to casting.
move to rn.
write rn.

*going from 66 to B

data : i type i value 66.
data : x type x.
field-symbols : type c.
move i to x.
assign x to casting type c.
move to c.
write c.

sap abap program for Figure to Words for India but can be modified to any requirement

* Test Program
Report ZJNC3.

Data: OffSet type I,
Amt2Words type String.


Selection-Screen: Begin of Block B1Opts with Frame Title TEXT-002.
Parameters: MyAmount type P Decimals 2 ,
MyChrsLn type I ,
MyNumLns type I .
Selection-Screen: End of Block B1Opts.


CALL FUNCTION 'ZAMT2WORDS'
EXPORTING
AMOUNT = MyAmount
CHRSLINE = MyChrsLn
NUMLINES = MyNumLns
CHANGING
AMT2WDS = Amt2Words.


Move 0 to OffSet.
Do MyNumLns Times.
Write: / Amt2Words+OffSet(MyChrsLn).
Add MyChrsLn to OffSet.
EndDo.

------------------------------------------------------------------------------------------
* Function Module ZAMT2WORDS

FUNCTION ZAMT2WORDS.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(AMOUNT) TYPE P
*" REFERENCE(CHRSLINE) TYPE I
*" REFERENCE(NUMLINES) TYPE I
*" CHANGING
*" REFERENCE(AMT2WDS) TYPE STRING
*"----------------------------------------------------------------------

* Nicely Cased words spelt corectly
* suits India
* takes care of singular & plural
* word wraps at line end
* ChrsLine = max no. of chars per line for wordwrapping.
* NumLines = max no. of lines

Data: chramount type String,
workStr type String,
numAmount type P Decimals 2.

Data: MyTwoDigits type I,
quotient type I,
remainder type I.

Data: cr type I,
lk type I,
th type I,
hun type I,
ten type I,
paisa type I.

Compute MAXLEN = ChrsLine * NumLines.

Move '' to mySpaces.
Do MAXLEN Times.
Concatenate mySpaces '.' into mySpaces.
EndDo.

Move ChrsLine to LineLength.

If LineLength <> 120.
Amt2Words = 'Invalid Parameters'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
Return.
EndIf.

If Amount = 0.
Amt2Words = 'Rupees Nil Only'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
Return.
EndIf.

* Reference is 'Seventeen'.

* Units & Teens
Words1 =
'One......' &
'Two......' &
'Three....' &
'Four.....' &
'Five.....' &
'Six......' &
'Seven....' &
'Eight....' &
'Nine.....' &
'Ten......' &
'Eleven...' &
'Twelve...' &
'Thirteen.' &
'Fourteen.' &
'Fifteen..' &
'Sixteen..' &
'Seventeen' &
'Eighteen.' &
'Nineteen.'.

Move '' to Words2.

* Tens
Words2 =
'Twenty...' &
'Thirty...' &
'Forty....' &
'Fifty....' &
'Sixty....' &
'Seventy..' &
'Eighty...' &
'Ninety...'.

If Amount < 0.
Amt2Words = 'Rupees Minus'.
Else.
Amt2Words = 'Rupees'.
EndIf.


* crlkthhtn.ps.
Compute numAmount = 1000000000 + Abs( Amount ).
Move numAmount to chramount.
Move chramount+1(2) to cr.
Move chramount+3(2) to lk.
Move chramount+5(2) to th.
Move chramount+7(1) to hun.
Move chramount+8(2) to ten.
Move chramount+11(2) to paisa.

If cr > 0.
Perform InWords2Digits Using cr.
If cr > 1.
Perform AppendWord Using 'Crores'.
Else.
Perform AppendWord Using 'Crore'.
EndIf.
EndIf.

If lk > 0.
Perform InWords2Digits Using lk.
If lk > 1.
Perform AppendWord Using 'Lakhs'.
Else.
Perform AppendWord Using 'Lakh'.
EndIf.
EndIf.

If th > 0.
Perform InWords2Digits Using th.
Perform AppendWord Using 'Thousand'.
EndIf.

If hun > 0.
Perform InWords2Digits Using hun.
Perform AppendWord Using 'Hundred'.
EndIf.

If ten > 0.
Perform InWords2Digits Using ten.
EndIf.

If paisa > 0.
If Amt2Words = 'Rupees'.
Amt2Words = 'Paisa'.
Else.
Perform AppendWord Using 'And'.
Perform AppendWord Using 'Paisa'.
EndIf.
Perform InWords2Digits Using paisa.
EndIf.

Perform AppendWord Using 'Only'.

Perform Rpad2MAX.

Amt2Wds = Amt2Words.

ENDFUNCTION.
------------------------------------------------------------------------------------------
* TOP level Include of Function Group ZUTIL

FUNCTION-POOL ZUTIL. "MESSAGE-ID ..

* Global ZUTIL Data
Data: Words1 type String,
Words2 type String,
Amt2Words type String,
mySpaces type String,
LineLength type I ,
MaxLen type I .

*&---------------------------------------------------------------------*
*& Form AppendWord
*&---------------------------------------------------------------------*
FORM AppendWord Using AddWord type String.

Data: NowLen type I,
AddLen type I,
NewLen type I,
DifLen type I,
workStr type String.

NowLen = StrLen( Amt2Words ).
NowLen = NowLen Mod LineLength.
AddLen = StrLen( AddWord ).

Compute NewLen = NowLen + 1 + AddLen.
If NewLen > LineLength.
DifLen = LineLength - NowLen.
If DifLen > 1.
Subtract 1 from DifLen.
Move mySpaces+0(DifLen) to workStr.
Concatenate Amt2Words workStr into Amt2Words.
EndIf.
EndIf.

* exact line boundary
If NowLen = 0.
Concatenate Amt2Words AddWord into Amt2Words.
Else.
Concatenate Amt2Words '.' AddWord into Amt2Words.
EndIf.

EndForm. " AppendWord

*&---------------------------------------------------------------------*
*& Form InWords2Digits
*&---------------------------------------------------------------------*
FORM InWords2Digits Using MyTwoDigits type I.
Data: quotient type I,
remainder type I,
workStr type String,
workIdx type I.

If MyTwoDigits > 19 .
Compute quotient = MyTwoDigits Div 10.
Compute remainder = MyTwoDigits Mod 10.

Compute workIdx = ( quotient - 2 ) * 9.
Move Words2+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.

If remainder > 0 .
Compute workIdx = ( remainder - 1 ) * 9.
Move Words1+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
EndIf.
Else.
Compute workIdx = ( MyTwoDigits - 1 ) * 9.
Move Words1+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
EndIf.

EndForm. " InWords2Digits

*&---------------------------------------------------------------------*
*& Form Rpad2MAX
*&---------------------------------------------------------------------*
FORM Rpad2MAX.
Concatenate Amt2Words mySpaces into Amt2Words.
Move Amt2Words+0(MAXLEN) to Amt2Words.
Concatenate Amt2Words '*' into Amt2Words.
Replace All Occurrences Of '.' in Amt2Words With ' !'.
Replace All Occurrences Of '!' in Amt2Words With ' '.
EndForm. " Rpad2MAX
------------------------------------------------------------------------------------------

sap abap conversion program for Print Number Value Without Thousand Separator

How can I print number value without thousand separator?

See Eg.
data mqty type p decimals 3 value '1234.45'.
write:/ mqty .

Result is : 1,234.45
And I want to print it like 1234.45

I usually using the REPLACE Command,

mqty = '1,234.45'.

REPLACE ',' WITH '' INTO mqty.

Or

REPLACE ',' WITH SPACE INTO mqty.

ABAP Tips by: Nurmansah

For thousand separator, you should write this program.

You can also write this program as function. You can call when it require.
ex:

DATA : x TYPE i,
chspec(10).

MOVE it_comm1-fobval TO chspec.
CONDENSE chspec.
x = STRLEN( chspec ) .

IF x LE 3.
chspec = ''.
ELSEIF x = 4.
chspec = '_,___'.
ELSEIF x = 5.
chspec = '__,___'.
ELSEIF x = 6.
chspec = '_,__,___'.
ELSEIF x = 7.
chspec = '_,__,___'.
ENDIF.

WRITE: 89(12) it_comm1-fobval RIGHT-JUSTIFIED USING EDIT MASK chspec.

it_comm1-fobval = '1234'
result
1,234

sap abap conversion program for Insert a special Tab Delimited Character

REPORT Z_DELIMIT_DOWNLOAD.

* Inserting a Tab Delimited between the Fields in the Internal Table
*
* This program allows you to insert any Tab Delimited characters easily.
*
* You have to create the customized Function in SE37 First.
*
* The customized functions will replace all the fields in your internal table
* with your desired Tab Delimited characters.
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
* http://www.sap-img.com
*
*
*Replace DELIMIT with "," in the function

DATA: BEGIN OF ITAB OCCURS 100,
TXT01(10),
TXT02(10),
END OF ITAB.

SELECTION-SCREEN BEGIN OF BLOCK FILE_OP WITH FRAME TITLE TEXT-030.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: DLOAD AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN COMMENT 4(30) TEXT-027.
PARAMETERS: FILE LIKE RLGRAP-FILENAME
DEFAULT 'C:\TEMP\ZTEST.TXT'.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK FILE_OP.

ITAB-TXT01 = 'TEXT01'.
ITAB-TXT02 = 'TEXT01'.
APPEND ITAB.

ITAB-TXT01 = 'TEXT02'.
ITAB-TXT02 = 'TEXT02'.
APPEND ITAB.

PERFORM DOWNLOAD.
*---------------------------------------------------------------------*
* FORM DOWNLOAD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM DOWNLOAD.

DATA: BEGIN OF DUMP OCCURS 0,
C(2048) TYPE C,
END OF DUMP.

REFRESH DUMP.
CALL FUNCTION 'Z_DELIMIT_DOWNLOAD'
EXPORTING
DELIMIT = ','
TABLES
INTAB = ITAB
OUTTAB = DUMP
EXCEPTIONS
CONVERSION_FAILED = 01.

LOOP AT DUMP.
WRITE:/ DUMP.
ENDLOOP.

CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'DAT'
MODE = ' '
TABLES
DATA_TAB = DUMP
EXCEPTIONS
FILE_OPEN_ERROR = 01
FILE_WRITE_ERROR = 02
INVALID_FILESIZE = 03
INVALID_TABLE_WIDTH = 04
INVALID_TYPE = 05
NO_BATCH = 06
UNKNOWN_ERROR = 07.
ENDFORM.

*************************************************
* This Function modules need to be created first.
*************************************************
FUNCTION Z_DELIMIT_DOWNLOAD .
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(DELIMIT)
*" TABLES
*" INTAB
*" OUTTAB
*"----------------------------------------------------------------------


FIELD-SYMBOLS: .

DATA: LEN TYPE I,
NUM TYPE I,
DELIMIT_LEN TYPE I.

DELIMIT_LEN = STRLEN( DELIMIT ).

LOOP AT INTAB.
CLEAR OUTTAB.
NUM = 0.
DO.
* Get name of next structure field into
ASSIGN COMPONENT SY-INDEX OF STRUCTURE INTAB TO .
IF SY-SUBRC <> 0. EXIT. ENDIF. " No more fields in structure

LEN = STRLEN( ).
WRITE: TO OUTTAB+NUM(LEN). " Write field to output table
NUM = NUM + LEN.

WRITE: DELIMIT TO OUTTAB+NUM(DELIMIT_LEN).
NUM = NUM + DELIMIT_LEN.
ENDDO.
APPEND OUTTAB.
ENDLOOP.
ENDFUNCTION.

sap abap program for Convert SAP Spool List to HTML

* Convert Spool List to HTML
*
* File save should have the extension .htm or .html
*
* Use a browser to open the file.

REPORT ZHTMLLIST LINE-SIZE 90 NO STANDARD PAGE HEADING.

TABLES: W3HTML.

DATA BEGIN OF INT_HTML OCCURS 0.
INCLUDE STRUCTURE W3HTML.
DATA END OF INT_HTML.

SY-TITLE = 'Convert Spool List to HTML'.

WRITE:/ 'Happiness lies in the joy of achievement and the thrill of'.
WRITE:/ 'creative effort.'.

NEW-PAGE.
WRITE:/ 'It is not enough to have great qualities, we should also'.
WRITE:/ 'have the management of them'.

call function 'LIST_DOWNLOAD_HTML'
EXPORTING
LIST_INDEX = 0
EXCEPTIONS
LIST_INDEX_INVALID = 1
DOWNLOAD_ERROR = 2
OTHERS = 3.

TOP-OF-PAGE.
WRITE:/ SY-TITLE, 'Page ', SY-PAGNO.

sap program for Convert Month to Word in ABAP

REPORT ZMONTH.

DATA X_MONTH(11).

CALL FUNCTION 'CONVERSION_EXIT_LDATE_OUTPUT'
EXPORTING
INPUT = SY-DATUM
IMPORTING
OUTPUT = X_MONTH.

WRITE:/ 'Month in words', X_MONTH+3(8).

*-- End of Program

ABAP function to convert Number to Words

*
* Converting Number to Words
*
* This function comes handy mostly for the Finance module as they need to print out check
* for the vendors. The function allows you to covert easily from numbers to words.
*
* Written by : SAP Basis ABAP Programming and Other IMG Stuff
* http://www.sap-img.com
*
REPORT ZSPELL.

TABLES SPELL.

DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.
DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '1234510'.

SY-TITLE = 'SPELLING NUMBER'.

PERFORM SPELL_AMOUNT USING PAMOUNT 'USD'.

WRITE: 'NUMBERS', T_SPELL-WORD, 'DECIMALS ', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING PWRBTR PWAERS.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = PAMOUNT
CURRENCY = PWAERS
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.
ENDFORM. " SPELL_AMOUNT

Blog Archive