Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.

...

En nuestro caso debemos poner virtual ya que accedemos a la LFA1.

5 - En caso de haber creado un atributo virtual, tendremos que definir un código para mapear el valor de ese atributo. Para ello nos posicionamos sobre el atributo dentro de la jerarquía y hacemos clic en el botón superior de "Programa".

El siguiente código es un ejemplo de como mapear el NIF del proveedor:

Bloque de código
languagetext
firstline1
titlePrograma ZBUS2012
linenumberstrue
*****           Implementation of object type ZBUS2012             *****
INCLUDE <object>.
begin_data object. " Do not change.. DATA is generated
* only private members may be inserted into structure private
DATA:
  " begin of private,
  "   to declare private attributes remove comments and
  "   insert private attributes here ...
  " end of private,
  BEGIN OF key,
    purchaseorder LIKE ekko-ebeln,
  END OF key,
  taxnumber1 TYPE lfa1-stcd1,
  name       TYPE lfa1-name1.
end_data object. " Do not change.. DATA is generated

TABLES lfa1.
DATA gs_lfa1 TYPE lfa1.

FORM update_lfa1.
  DATA: lv_order TYPE ekko-ebeln.
  lv_order = object-key-purchaseorder.

  CLEAR gs_lfa1.
  SELECT SINGLE *
    FROM ekko AS a
    INNER JOIN lfa1 AS b ON a~lifnr EQ b~lifnr
    INTO CORRESPONDING FIELDS OF gs_lfa1
    WHERE a~ebeln EQ lv_order.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
ENDFORM.

get_property taxnumber1 changing container.
IF gs_lfa1 IS INITIAL.
  PERFORM update_lfa1.
ENDIF.

IF gs_lfa1-stceg IS NOT INITIAL.
  object-taxnumber1 = gs_lfa1-stceg.
ELSEIF gs_lfa1-stcd1 IS NOT INITIAL.
  object-taxnumber1 = gs_lfa1-stcd1.
ELSEIF gs_lfa1-stcd2 IS NOT INITIAL.
  object-taxnumber1 = gs_lfa1-stcd2.
ELSEIF gs_lfa1-stcd3 IS NOT INITIAL.
  object-taxnumber1 = gs_lfa1-stcd3.
ELSEIF gs_lfa1-stcd4 IS NOT INITIAL.
  object-taxnumber1 = gs_lfa1-stcd4.
ENDIF.

swc_set_element container 'TaxNumber1' object-taxnumber1.
end_property.

6 - Una vez guardado el programa. Volvemos a la pantalla del BO con la jerarquía y hacemos clic en el botón de generar Image Added.

7 - Volvemos a la pantalla principal de la SWO1 e informamos el BO estándar del que creamos el subtipo Z y hacemos clic en Opciones/Delegación:

Image Added

8 - Por último, crearemos una nueva entrada de delegación para el BO BUS2012 indicando que herede de la ZBUS2012 con los nuevos atributos.

Image Added