字母加数字取号码段
REPORT YSARIEL. "Create by Sariel PARAMETERS P_CHAR TYPE CHAR4 OBLIGATORY. "任意长 PARAMETERS P_NUMC TYPE NUMC4 OBLIGATORY. "任意长 PERFORM FRM_GET_RSTR. FORM FRM_GET_RSTR . WRITE / P_CHAR && P_NUMC. IF P_NUMC EQ '9999'. "按定义最大值 DATA(LV_LEN) = STRLEN( P_CHAR ) - 1. PERFORM FRM_GET_CHAR CHANGING LV_LEN P_CHAR. WRITE / P_CHAR && '0000'. "按定义最小值 ELSE. P_NUMC = P_NUMC + 1. WRITE / P_CHAR && P_NUMC. ENDIF. ENDFORM. FORM FRM_GET_CHAR CHANGING CV_INDX CV_CHAR. DATA LS_RESULT TYPE MATCH_RESULT. IF CV_INDX LT 0. MESSAGE 'Max!' TYPE 'E'. ENDIF. FIND CV_CHAR+CV_INDX(1) IN SY-ABCDE RESULTS LS_RESULT. IF SY-SUBRC EQ 0. IF LS_RESULT-OFFSET EQ 25. CV_CHAR+CV_INDX(1) = 'A'. DATA(LV_INDX) = CV_INDX - 1. PERFORM FRM_GET_CHAR CHANGING LV_INDX CV_CHAR. ELSE. DATA(LV_OFFSET) = LS_RESULT-OFFSET + 1. CV_CHAR+CV_INDX(1) = SY-ABCDE+LV_OFFSET(1). ENDIF. ENDIF. ENDFORM. " FRM_GET_CHAR