How to convert A00073 value to 9973 in progress 4gl

前端 未结 5 1873
日久生厌
日久生厌 2021-01-29 04:37

i have column having multiple value like A0045 ,A00065 . i want to convert it 9945, 9965. Need to remove all 0 and character value and add 99 before that value.. Please help..

5条回答
  •  时光取名叫无心
    2021-01-29 05:10

    Please do let me know if this works for you, Progress not installed so couldn't compile and test.

    /* A0045 -> 9945 A00065 -> 9965 */

    DEFINE VARIABLE v_RawData AS CHARACTER NO-UNDO.
    DEFINE VARIABLE v_InpData AS CHARACTER NO-UNDO.
    DEFINE VARIABLE i         AS INTEGER NO-UNDO.
    DEFINE VARIABLE j         AS INTEGER NO-UNDO.
    
    ASSIGN v_RawData = "A0045,A00065".
    
    DO i =1 TO NUM-ENTRIES(v_RawData):
        ASSIGN v_InpData = ENTRY(i,v_RawData).
    
        DO j = 1 TO LENGTH(v_InpData):
            IF ASC(SUBSTRING(v_InpData,j,1)) > 48 AND 
               ASC(SUBSTRING(v_InpData,j,1)) < 58 THEN
                DO:
                    LEAVE.
                END.
        END.
        MESSAGE REPLACE(v_InpData,SUBSTRING(v_InpData,1,j - 1),"99").
    END.
    

提交回复
热议问题