miércoles, 29 de diciembre de 2010

Transformation routines

1.- El clásico delete DELETE DATA_PACKAGE es ahora

DATA: l_tabix TYPE sy-tabix,
wa_source_package TYPE _ty_s_sc_1.

LOOP AT source_package
INTO wa_source_package.
l_tabix = sy-tabix.

IF ( wa_source_package-processkey NE '001' AND
wa_source_package-processkey NE '011' AND
wa_source_package-processkey NE '021' AND
wa_source_package-processkey NE '002' AND
wa_source_package-processkey NE '012' AND
wa_source_package-processkey NE '022' ) OR
wa_source_package-CPQUAOU EQ 0 OR
wa_source_package-numerator EQ 0 OR
wa_source_package-denomintr EQ 0.
DELETE
source_package
INDEX
l_tabix.

ENDIF.

ENDLOOP.
Ex: completar un dato en las subida
clear result.
select single /BIC/Z_GROUP
into result
from /BI0/PPROD_HIER
where PROD_HIER = SOURCE_FIELDS-PRDHA
and OBJVERS eq 'A'.




Ex.: 0COSTCENTER-->Cost center hierarchy

select single * from rshiedir into hier_wa where
objvers eq 'A' and
hietype eq '1' and
hienm eq hier_name and
dateto ge sy-datum .
if sy-subrc ne 0 .
raise invalid_hierarchy .
endif .

clear hier_detail .
move: hier_wa-hieid to hier_detail-hieid ,
hier_wa-objvers to hier_detail-objvers .


call function 'RSSH_HIERARCHY_READ'
exporting
i_rshiedirkey = hier_detail
* I_RSHIEDIRLOG =
i_date = sy-datum
importing
e_rshiedir = e_rshiedir
e_t_rsnodes = e_t_rsnodes
e_th_rsinterval = e_th_rsinterval
e_duplicate_leafs = e_duplicate_leafs
e_t_rsnodes_lnk = e_t_rsnodes_lnk
exceptions
invalid_hierarchy = 1
name_error = 2
iobj_not_found = 3
others = 4 .
case sy-subrc .

martes, 28 de diciembre de 2010

Atajo a SAP

Standard SAP GUI doesn’t allows to save password in the shortcuts. This can be achieved by doing these two steps.

1.) Executing sapshcut.exe which normally exists at C:\Program Files\SAP\FrontEnd\SAPgui.
Once this step is done then the variables which needs to be modified in REGEDIT are available for editing.

2.) Go to Command Prompt and type in REGEDIT -> HKEY_CURRENT_USER –> Software –> SAP –> SAPShortcut –> Security, Change the variable Enable Password from O to 1.

martes, 21 de diciembre de 2010

Obtener el año a partir de una fecha y restar 2 años

Coger la fecha de un prompt y restarle para conseguir en año n-2:

FormatNumber((Year(ToDate(UserResponse("Data fixada");""))-2);"####")

A partir del mes-año del prompt y restarle para conseguir en año n-2:

FormatNumber(ToNumber(Right(UserResponse("Mes analise (MMYYYY)");4))-2;"####")

Como extraer la clasificación del lote

Si sacaramos esto con código tendría que ser algo así:
* DATA:
* ld_tabix LIKE sy-tabix,
* v_matlot(28) TYPE c,
* v_atwrt LIKE ausp-atwrt,
* v_cuobj LIKE inob-cuobj,
* v_atinn LIKE cabn-atinn,
* v_clint LIKE klah-clint.

clear: v_atwrt, v_matlot, v_cuobj, v_atinn.
if not r_mc12vc0itm-charg is initial.
if not r_mc12vc0itm-matnr is initial.

CONCATENATE r_mc12vc0itm-matnr r_mc12vc0itm-charg INTO v_matlot.

SELECT SINGLE cuobj FROM inob INTO v_cuobj
WHERE klart = '023'
AND objek = v_matlot.

CALL FUNCTION 'CONVERSION_EXIT_ATINN_INPUT'
EXPORTING
input = 'CENTRO'
IMPORTING
output = v_atinn.

SELECT atwrt FROM ausp INTO v_atwrt UP TO 1 ROWS
WHERE objek = v_cuobj
AND atinn = v_atinn
AND klart = '023'
AND atzhl = 1.
ENDSELECT.

r_mc12vc0itm-zzwerks_fb = v_atwrt.
endif.
endif.


Se trata de evitar todo esto y sacar estos datos utilizando el standar:
Bases:
Datos del maestro del lote: MCH1.
Datos de clase maesro para el lote (023): CL03.

A diferencia del material, el lote no tiene el correspondiente extractor _ATTR.
Entonces:
Paso 1) crear un extractor de atributos para el lote en la RSO2, si se quiere derectamente sobre la tabla (MCH1 o MCHA) o se puede hacer una vista más personal
Paso 2) crear el extractor para la clasificación en la CTBW
Paso 3) crear el correspondiente infoobjeto en BW

jueves, 16 de diciembre de 2010

Movimientos de materiales

Problemas típicos:

2lis_03_BF
* los campos BW* estan a cero, ej. el BWMNG --> solución:
Activar la determinación del process KEY: MCB_
Activar el flag de BW en la BF11

Note 353042 - Howto: Activate transaction key (PROCESSKEY)
Note 352344 -> Process key + reversals in Inventory Management(Consulting note). 

miércoles, 15 de diciembre de 2010

Codigo para obtener "Sourrce System R/3 Entty

CALL FUNCTION 'RSDG_ID_GET_FROM_LOGSYS'
EXPORTING
i_source_system = G_S_MINFO-LOGSYS
IMPORTING
e_soursysid = RESULT
EXCEPTIONS
id_not_found = 1.