Monday, November 30, 2020

How to Convert Number to Words in Crystal report (In words)

--In words useful

numbervar Amt:=0; 

numbervar pAmt:=0; 


numbervar RmCrore:=0;

numbervar RmLac:=0;


stringvar InWords :=""; 

Amt := {@GRAND_TOTAL}; //640034500059.88; 10048733.10;


if Amt >= 10000000 then RmCrore := truncate(Amt/10000000);


if RmCrore = 1 then 

InWords := InWords + "" + ProperCase (towords(RmCrore,0)) + " Crore" 

else 

if RmCrore > 1 then InWords := InWords + " " + ProperCase (towords(RmCrore,0)) + " Crore"; 


Amt := Amt - RmCrore * 10000000;


if Amt>=100000 then

(


    if Amt >= 100000 then RmLac := truncate(Amt/100000); 


    if RmLac = 1 then 

    InWords := InWords + " " + ProperCase (towords(RmLac,0)) + " Lac";


    If RmLac > 1 then InWords := InWords + " " +  ProperCase (ToWords(RmLac,0)) + " Lac";


); 


    Amt := Amt - RmLac * 100000; 

    if Amt > 0 then InWords := InWords + " " +  ProperCase (towords(truncate(Amt),0));

    pAmt := (Amt - truncate(Amt)) * 100; 


    InWords := InWords+" Taka";

    if pAmt > 0 then 

    InWords := InWords + " and " +  ProperCase (towords(pAmt,0)) + " paise Only." 

    else 

    InWords := InWords + " Only.";


Propercase(InWords);


    

---------------------------------------------------------------------------------------------------------------



 if

right(Totext({amount}),2)="00"

then

uppercase(ToWords({amount},0))+" "+"Only"

else

uppercase(ToWords({amount},0))+" AND "+uppercase(ToWords(tonumber(right(Totext({amount}),2)),0))+" "+"Paisa Only"



-----------------------------------------------------------------------------------------------------------------------


----use it 


currencyvar Original;


currencyvar deci;


Original:={@ToBePaid};


deci:= Original- Truncate(Original);


Original:= truncate(Original);


deci:= deci* 100;


if deci= 0 then  ToWords (Original,0 ) + ' Only'


else


ProperCase(ToWords (Original,0)) + ' And ' + ProperCase(ToWords(deci,0)) + ' Paisa Only ';


-----------------------


OK 


numbervar RmVal:=0;

numbervar Amt:=0;

numbervar pAmt:=0;

stringvar InWords :="Taka";


Amt := ROUND({QR_CHECKPAYMENT_VOUCHER\\.AMOUNT},0);


    if Amt > 10000000 then RmVal := truncate(Amt/10000000);

    if Amt = 10000000 then RmVal := 1;

    if RmVal = 1 then

        InWords := InWords + " " + towords(RmVal,0) + " crore"

    else

    if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crore";

 

Amt := Amt - Rmval * 10000000;


    if Amt > 100000 then RmVal := truncate(Amt/100000);

    if Amt = 100000 then RmVal := 1;

    if Amt = 0 then RmVal := 0;

    if RmVal >= 1 then

    InWords := InWords + " " + towords(RmVal,0) + " lac";

 

Amt := Amt - Rmval * 100000;


    if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);

    pAmt := (Amt - truncate(Amt)) * 100;

    if pAmt > 0 then

    InWords := InWords + " and " + towords(pAmt,0) + " paisa only"

    else

    InWords := InWords + " only";

    Propercase(InWords)



https://www.aspforums.net/Threads/397348/Convert-Number-Currency-to-word-in-Crystal-Report/

-----------------------------------------------------------------------------------------------------------------------

---- Basic Structure 

https://stackoverflow.com/questions/32049317/convert-decimal-value-into-words-in-crystal-report

currencyvar Original;

currencyvar deci;

Original:={@AmountInDecimal};

deci:= Original- Truncate(Original);

Original:= truncate(Original);

deci:= deci* 100;

if deci= 0 then 'Rupees ' + ToWords (Original,0 ) + ' Only'

else

'Rupees ' + ToWords (Original,0) + ' And Paisa ' + ToWords(deci,0) + ' Only ';





------------------------------------------------------------------------------------------------------------------------------------


CREATE OR REPLACE function In_Word(a_number number) return char is

type numtab is table of

varchar2(30)

index by binary_integer;

number_chart numtab;

crore number;

lakh number;

thou number;

hund number;

doubl number;

sing number;

deci number;

text varchar2(500);

begin

--The Table

number_chart(1):='One';

number_chart(2):='Two';

number_chart(3):='Three';

number_chart(4):='Four';

number_chart(5):='Five';

number_chart(6):='Six';

number_chart(7):='Seven';

number_chart(8):='Eight';

number_chart(9):='Nine';

number_chart(10):='Ten';

number_chart(11):='Eleven';

number_chart(12):='Twelve';

number_chart(13):='Thirteen';

number_chart(14):='Fourteen';

number_chart(15):='Fifteen';

number_chart(16):='Sixteen';

number_chart(17):='Seventeen';

number_chart(18):='Eighteen';

number_chart(19):='Nineteen';

number_chart(20):='Twenty';

number_chart(30):='Thirty';

number_chart(40):='Forty';

number_chart(50):='Fifty';

number_chart(60):='Sixty';

number_chart(70):='Seventy';

number_chart(80):='Eighty';

number_chart(90):='Ninety';

crore:=floor(a_number/10000000);

lakh:=floor((a_number-trunc(a_number,-7))/100000);

thou:=floor((a_number-trunc(a_number,-5))/1000);

hund:=floor((a_number-trunc(a_number,-3))/100);

doubl:=trunc(a_number-trunc(a_number,-2),0);

sing:=trunc(a_number-trunc(a_number,-1),0);

deci:=(a_number-trunc(a_number,0))*100;

if crore<>0 then

 text:=In_Word(crore)||' '||'Crore ';

end if;

if lakh <>0 then

 if (lakh<=20)  or  (lakh mod 10=0) then

  text:=text||number_chart(lakh)||' Lac ';

 else

  text:=text||number_chart(trunc(lakh,-1))||' '||number_chart(trunc(lakh,0)-trunc(lakh,-1))||' Lac ';

 end if;

end if;

if thou <>0 then

 if (thou<=20)  or  (thou mod 10=0) then

  text:=text||number_chart(thou)||' Thousand ';

 else

  text:=text||number_chart(trunc(thou,-1))||' '||number_chart(trunc(thou,0)-trunc(thou,-1))||' Thousand ';

 end if;

end if;

if hund <>0 then

 if (hund<=20)  or  (hund mod 10=0) then

  text:=text||number_chart(hund)||' Hundred ';

 else

  text:=text||number_chart(trunc(hund,-1))||' '||number_chart(trunc(hund,0)-trunc(hund,-1))||' Hundred ';

 end if;

end if;

if doubl <>0 then

 if (doubl<=20)  or  (doubl mod 10=0) then

  text:=text||number_chart(doubl)||' ';

 else

  text:=text||number_chart(trunc(doubl,-1))||' '||number_chart(trunc(doubl,0)-trunc(doubl,-1))||' ';

 end if;

end if;

if deci <>0 then

 if (deci<=20)  or  (deci mod 10=0) then

  text:=text||'and '||number_chart(deci)||' Paisa ';

 else

  text:=text||'and '||number_chart(trunc(deci,-1))||' '||number_chart(trunc(deci,0)-trunc(deci,-1))||' Paisa ';

 end if;

end if;

if text is not null then

return(text||'Only');

else

return(text);

end if;

end In_Word;

/


-------------------------------------------------------------------------------------------------------------------------------------

Formula column 


round((Sum ({X_TRANSPORTBILL_REP.AMOUNT_IN})-{@Total_Adjust_Amount}),2)


-------------------------------------------------------------------------------------------------------------------------------------


numbervar RmVal:=0;

numbervar Amt:=0;

numbervar pAmt:=0;

stringvar InWords :="Taka ";

Amt := ({@ToBePaid});

if Amt > 10000000 then RmVal := truncate(Amt/10000000);

if Amt = 10000000 then RmVal := 1;

if RmVal = 1 then

InWords := InWords + " " + towords(RmVal,0) + " crore"

else

if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";

 

Amt := Amt - Rmval * 10000000;

if Amt > 100000 then RmVal := truncate(Amt/100000);

if Amt = 100000 then RmVal := 1;

if Amt = 0 then RmVal := 0;

if RmVal >= 1 then

InWords := InWords + " " + towords(RmVal,0) + " lac";

 

Amt := Amt - Rmval * 100000;

if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);

pAmt := (Amt - truncate(Amt)) * 100;

if pAmt > 0 then

InWords := InWords + " and " + towords(pAmt,0) + " paisa only"

else

InWords := InWords + " only";

ProperCase(InWords)


Wednesday, November 18, 2020

REGEX to Split a Comma-Separated String into Rows

 CREATE TABLE T1

 (

 DATA                                               VARCHAR2(50)

 )

 /

INSERT INTO T1 VALUES('GTY');

INSERT INTO T1 VALUES('GAT');

INSERT INTO T1 VALUES('GPL');

SQL> SELECT * FROM T1;

DATA

----------------------------------

GTY

GAT

GPL

SELECT              *

FROM                T1

WHERE              DATA IN

                        (

                            SELECT                 

                                                      REGEXP_SUBSTR(:P_COMPANY,'[^;]+', 1, LEVEL)

                             FROM                 DUAL

                             CONNECT BY      REGEXP_SUBSTR(:P_COMPANY, '[^;]+', 1, LEVEL)

                                                      IS NOT NULL)

/



 HTTPS://WWW.ORATABLE.COM/REGEX-SPLIT-COMMA-SEPARATED-STRING/

Monday, November 16, 2020

SAP Crystal Report Shortcuts keys

Menu Bar Shortcut Keys

Create New Report                             Ctrl + N
Open Report                                      Ctrl + O
Save Report                                      Ctrl + S
Print Report                                      Ctrl + P
Cut                                              Ctrl + X
Copy                                              Ctrl + C
Paste                                              Ctrl + V
Delete                                              Del
Select All                                      Ctrl + A
Find                                              Ctrl + F
Go To Page                                      Ctrl + G
Design View                                      Ctrl + D
Refresh Report Data                                 F5

Formula Editor Shortcut Keys

Browse selected fieldAlt + B
Check for ErrorsAlt + C
Toggle the “Shows Field” treeAlt + F
Comment the current lineAlt + M
Sort tree contentAlt + O
Toggle the “Shows Operator” treeAlt + P
Save formulaAlt + S
Toggle the “Shows Function” treeAlt + U

 Formula Editor Shortcut Keys

Select allCtrl + A
CopyCtrl + C
Move to end of last formula lineCtrl + End
FindCtrl + F
Set a bookmarkCtrl + F2
Clear all bookmarksCtrl + Shift + F2
Move to beginning of fileCtrl + Home
Move to start of word at leftCtrl + <-
Select through start of word at leftCtrl + Shift + <-
Open a dialog to create a new formulaCtrl + N
Save and close Formula EditorCtrl + S
Focus to the syntax name list boxCtrl + T
Switch to previous control boxCtrl + Shift + Tab
Switch to next control boxCtrl + Tab
PasteCtrl + V
CutCtrl + X
UndoCtrl + Z
RepeatCtrl + Shift + Z
Keyword Auto CompleteCtrl + Space
Move to end of lineEnd
Copy object from list to formula boxEnter
Go to next bookmarkF2
Find next itemF3
Go to previous bookmarkShift + F2

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...