Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Include ZXMG0U08
*&---------------------------------------------------------------------*
DATA:
lv_identnr_last TYPE zz_identnr,
lv_identnr_next TYPE zz_identnr,
lv_matnr_last TYPE matnr,
lv_matnr_matchcode TYPE matnr,
lv_postfix TYPE matnr.
* Materialnummer separat merken.
IF matnr EQ '.'.
GET PARAMETER ID 'ZGROB_MATNR_LAST' FIELD matnr.
SET PARAMETER ID 'ZGROB_MATNR_SAVE' FIELD matnr.
ENDIF.
IF matnr CN '0123456789 '. " mit Leerzeichen!
SELECT SINGLE matnr FROM mara
INTO matnr
WHERE matnr = matnr.
CHECK sy-subrc NE 0.
* --- Suchhilfe aufrufen -----------------------------------------------
IF matnr CA '*' OR matnr CA '+'.
MOVE matnr TO lv_matnr_matchcode.
REPLACE ALL OCCURRENCES OF '*' IN lv_matnr_matchcode WITH '%'.
REPLACE ALL OCCURRENCES OF '+' IN lv_matnr_matchcode WITH '_'.
SELECT COUNT(*) FROM mara
WHERE zz_identnr LIKE lv_matnr_matchcode.
CASE sy-dbcnt.
WHEN 0. " keine weitere Aktion notwendig
WHEN 1. " bei genau 1 Treffer Materialnummer übernehmen
SELECT SINGLE matnr FROM mara
INTO matnr
WHERE zz_identnr LIKE lv_matnr_matchcode.
WHEN OTHERS. " Suchhilfe aufrufen
* CONCATENATE '=7...' matnr INTO matnr.
EXPORT matnr FROM matnr TO MEMORY ID 'ZGROB_MATNR_SHLP'.
MOVE '=9' TO matnr.
ENDCASE.
* --- Postfix mit gemerkter GROIB Identnummer verwenden ----------------
ELSEIF matnr CS '#' OR matnr CS '.'.
MOVE matnr TO lv_postfix.
SHIFT lv_postfix BY sy-fdpos PLACES LEFT.
SHIFT lv_postfix BY 1 PLACES LEFT.
IF matnr CS '#'.
GET PARAMETER ID 'ZGROB_MATNR_LAST' FIELD lv_matnr_last.
ELSE.
GET PARAMETER ID 'ZGROB_MATNR_SAVE' FIELD lv_matnr_last.
ENDIF.
* nicht CONVERSION_EXIT_MATN1_INPUT verwenden => Rekursion!
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_matnr_last
IMPORTING
output = lv_matnr_last
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SELECT SINGLE zz_identnr FROM mara
INTO lv_identnr_last
WHERE matnr = lv_matnr_last.
CONCATENATE lv_identnr_last lv_postfix INTO lv_identnr_next.
SELECT SINGLE matnr FROM mara
INTO matnr
WHERE zz_identnr = lv_identnr_next.
* --- GROB Identnummer auswerten ---------------------------------------
ELSE.
SELECT SINGLE matnr FROM mara
INTO matnr
WHERE zz_identnr = matnr.
SET PARAMETER ID 'ZGROB_MATNR_LAST' FIELD matnr.
ENDIF.
* --- nur Materialnummer merken ----------------------------------------
ELSE.
SET PARAMETER ID 'ZGROB_MATNR_LAST' FIELD matnr.
ENDIF.
Code: Alles auswählen.
IF CALLCONTROL-STEP = 'PRESEL'.
* PERFORM PRESEL ..........
data: lv_matnr type matnr,
lv_zzidentnr type zz_identnr,
lv_value_exist type c,
lt_selopt type DDSHSELOPS WITH HEADER LINE.
IMPORT matnr to lv_matnr from MEMORY ID 'ZGROB_MATNR_SHLP'.
FREE MEMORY ID 'ZGROB_MATNR_SHLP'.
* GET PARAMETER ID 'ZGROB_MATNR_SHLP' FIELD lv_zzidentnr.
if lv_matnr is NOT INITIAL.
move lv_matnr to lv_zzidentnr.
APPEND LINES OF shlp-selopt to lt_selopt.
LOOP AT lt_selopt
WHERE shlpfield = 'ZZ_IDENTNR'.
lv_value_exist = 'X'.
EXIT.
ENDLOOP.
IF lv_value_exist IS INITIAL.
CLEAR lt_selopt.
lt_selopt-shlpname = shlp-shlpname.
lt_selopt-shlpfield = 'ZZ_IDENTNR'.
lt_selopt-sign = 'I'.
lt_selopt-option = 'CP'.
lt_selopt-low = lv_zzidentnr.
APPEND lt_selopt TO shlp-selopt.
ENDIF.
ENDIF.
EXIT.
ENDIF.