APO CIF error:
No location 1000 exists for mapping entry
Use below program fix it, you own the risk.
*&---------------------------------------------------------------------*
*& Report ZUPDATE_LOCATION
*& This report used to fix the error message like:
*& No location 0000001002 exists for mapping entry 0000001002 of cat. 1011 B
*& this is due to you CIFed location data before you implement BADI SMOD_APOCF001,
*& locno in /SAPAPO/LOCMAP and /SAPAPO/LOC missed prefix as a result.
*& but this program can only correct location with internal number.
*&---------------------------------------------------------------------*
REPORT ZUPDATE_LOCATION.
TABLES: /SAPAPO/LOCMAP.
DATA: LT_LOCMAP TYPE STANDARD TABLE OF /SAPAPO/LOCMAP WITH HEADER LINE,
LT_LOC TYPE STANDARD TABLE OF /SAPAPO/LOC WITH HEADER LINE,
PREFIX TYPE /SAPAPO/C_LOCTYPE.
* method: IF_EX_SMOD_APOCF001~EXIT_/SAPAPO/SAPLCIF_LOC_001
SELECT-OPTIONS: S_LOCNO FOR /SAPAPO/LOCMAP-LOCNO.
SELECT * FROM /SAPAPO/LOCMAP INTO TABLE LT_LOCMAP WHERE LOCNO IN S_LOCNO
. " WHERE LOCNO LIKE '0%'.
CHECK SY-SUBRC EQ 0.
LOOP AT LT_LOCMAP.
" FIND FIRST OCCURRENCE OF REGEX '[0-9]' IN LT_LOCMAP-LOCNO(1).
PERFORM DETERMINE_PREFIX USING LT_LOCMAP-LOCTYPE CHANGING PREFIX.
IF LT_LOCMAP-LOCNO(2) <> PREFIX.
CONCATENATE PREFIX LT_LOCMAP-EXT_LOCNO INTO LT_LOCMAP-LOCNO.
MODIFY LT_LOCMAP.
MODIFY /SAPAPO/LOCMAP FROM LT_LOCMAP. " start to update system table.
UPDATE /SAPAPO/LOC SET LOCNO = LT_LOCMAP-LOCNO WHERE LOCID = LT_LOCMAP-LOCID.
NEW-LINE.
write: / SY-TABIX, ' Location changed to ', LT_LOCMAP-LOCNO, 'GUID', LT_LOCMAP-LOCID.
ELSE.
DELETE LT_LOCMAP.
ENDIF.
ENDLOOP.
GET TIME.
FORM DETERMINE_PREFIX USING LV_LOCTYPE TYPE /SAPAPO/C_LOCTYPE CHANGING PREFIX TYPE /SAPAPO/C_LOCTYPE.
CLEAR PREFIX.
CASE LV_LOCTYPE.
WHEN '1001'.
PREFIX = 'PL'. " Plant
WHEN '1002'.
PREFIX = 'DC'. " Distribution Center
WHEN '1003'.
PREFIX = 'SP'. " Shipping Point
WHEN '1005'.
* Transportation zone numbers look always like:
* US-1234567890 -> These are already 13 characters
* Adding @XXXNNN (XXX = BSG, NNN = client) we have 20 characts.
* So we can't add a prefix like TZ -> Transp.zones have no prefix!
CLEAR PREFIX. " Transportation Zone
WHEN '1007'.
PREFIX = 'MR'. " MRP Area
WHEN '1010'.
PREFIX = 'CU'. " Customer
WHEN '1011'.
PREFIX = 'SU'. " Supplier
WHEN '1020'.
PREFIX = 'CA'. " Carrier
WHEN '1040'.
PREFIX = 'ST'. " Store
ENDCASE.
ENDFORM.
No comments:
Post a Comment