viernes, 23 de noviembre de 2012

Modificar documento CV03N

Al correr el programa Crear documento CV01N sube la informacion del documento, y con este codigo modificamos o borramos campos.
Al crearlo.
Al modificarlo.
 


DATA: aid TYPE sdok_loid,
      fid TYPE sdok_phid,
      dir TYPE draddir.
DATA: ls_doc LIKE bapi_doc_draw2,
      ls_docx  LIKE bapi_doc_drawx2,
      ls_return LIKE bapiret2,
      it_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
      it_files2 LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
      wa_files2 LIKE it_files,
      lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,
      it_link LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE,
      it_link2 LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE,
      wa_link2 LIKE it_link2.

ls_doc-documenttype = 'DRW'.
ls_doc-documentnumber = 'CH5000Q'.
ls_doc-documentversion = '00'.
ls_doc-documentpart = '000'.

ls_doc-description = 'Prueba descripcion'.
ls_docx-description = 'X'.
ls_doc-username = 'Hgomez'.
ls_docx-username = 'X'.

CLEAR it_files2.
REFRESH it_files2.

CLEAR it_link2.
REFRESH it_link2.

CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
  EXPORTING
   documenttype               = 'DRW'
   documentnumber             = 'CH5000Q'
   documentpart               = '000'
   documentversion            = '00'
   getobjectlinks             = 'X'
   getcomponents              = 'X'
   getstatuslog               = 'X'
   getlongtexts               = 'X'
   getactivefiles             = 'X'
   getdocdescriptions         = 'X'
   getdocfiles                = 'X'
   getclassification          = 'X'
   getstructure               = 'X'
   getwhereused               = 'X'
   hostname                   = 'X'
*   INHERITED                  =
* IMPORTING
*   DOCUMENTDATA               =
*   RETURN                     =
 TABLES
   objectlinks                = it_link2
*   DOCUMENTDESCRIPTIONS       =
*   LONGTEXTS                  =
*   STATUSLOG                  =
   documentfiles              = it_files2
*   COMPONENTS                 =
*   CHARACTERISTICVALUES       =
*   CLASSALLOCATIONS           =
*   DOCUMENTSTRUCTURE          =
*   WHEREUSEDLIST              =
          .
LOOP AT it_files2 INTO wa_files2 WHERE docfile = 'C:\hi.doc'.
  aid = wa_files2-application_id.
  fid =  wa_files2-file_id.
ENDLOOP.

CLEAR it_files.
REFRESH it_files.
*it_files-ORIGINALTYPE = 1. "INGRESAR
it_files-deletevalue     = 'X'.  "PARA BORRAR
it_files-docfile         = 'C:\hi.doc'.
it_files-wsapplication   = 'WWI'.
*it_files-ACTIVE_VERSION = 'X'. "INGRESAR
it_files-application_id  = aid. "PARA BORRAR
it_files-file_id         = fid. "PARA BORRAR
APPEND it_files.


LOOP AT it_link2 INTO wa_link2 WHERE objectkey = '098010254'.
  dir = wa_link2-documentdirection.
ENDLOOP.

CLEAR it_link.
REFRESH it_link.
it_link-deletevalue       = 'X'. "PARA BORRAR
it_link-objecttype        = 'MARA'.
it_link-objectkey         = '098010254'.
it_link-documentdirection = dir. "PARA BORRAR
APPEND it_link.


CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
  EXPORTING
    documenttype               = ls_doc-documenttype
    documentnumber             = ls_doc-documentnumber
    documentpart               = ls_doc-documentpart
    documentversion            = ls_doc-documentversion
    documentdata               = ls_doc
    documentdatax              = ls_docx
*   HOSTNAME                   =
*   DOCBOMCHANGENUMBER         =
*   DOCBOMVALIDFROM            =
*   DOCBOMREVISIONLEVEL        =
*   SENDCOMPLETEBOM            = ' '
*   PF_FTP_DEST                = ' '
*   PF_HTTP_DEST               = ' '
*   CAD_MODE                   = ' '
*   ACCEPT_EMPTY_BOM           = ' '
 IMPORTING
    return = ls_return
 TABLES
*   CHARACTERISTICVALUES       =
*   CLASSALLOCATIONS           =
*   DOCUMENTDESCRIPTIONS       =
    objectlinks                =  it_link
*   DOCUMENTSTRUCTURE          =
   documentfiles               =  it_files
*   LONGTEXTS                  =
*   COMPONENTS                 =
.

IF ls_return-type CA 'EA'.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  MESSAGE ID '26' TYPE 'I' NUMBER '000'
  WITH ls_return-message.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
  MESSAGE 'DMS MODIFICADO'  TYPE 'S'.
ENDIF.

Crear documento CV01N

Este codigo ingresa un documento a la CV01N.




**Datos del documento
DATA: l_docu   LIKE bapi_doc_draw2,
      l_values LIKE bapi_characteristic_values,
      l_allo   LIKE bapi_class_allocation,
      l_estryc LIKE bapi_doc_structure,
*retorna la badi
      l_return LIKE bapiret2.


*Estructura del documento
DATA: l_doctype     LIKE bapi_doc_draw2-documenttype,
      l_docnumber   LIKE bapi_doc_draw2-documentnumber,
      l_docpart     LIKE bapi_doc_draw2-documenttype,
      l_docversion  LIKE bapi_doc_draw2-documenttype.

DATA: it_files   LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
      it_descrip LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,
      it_link    LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

*Estrutura de inicio Tcode CV01N
l_docu-documentnumber  = 'CH0153Q'.
l_docu-documenttype    = 'DRW'.
l_docu-documentpart    = '000'.
l_docu-documentversion = '00'.
*Datos del documento
l_docu-statusintern   = 'AA'.
l_docu-description    = 'Prueba bAPI'.

REFRESH it_files.
CLEAR it_files.

*Originales
it_files-originaltype = 1.
it_files-docfile      = 'C:\hi.doc'.
it_files-wsapplication = 'WWI'.
it_files-active_version = 'X'.
APPEND it_files.

CLEAR it_descrip.
REFRESH it_descrip.

*Idioma descripcion
it_descrip-language    = 'ES'.
it_descrip-description = 'Prueba BAPI'.
APPEND it_descrip.

** Objectos de enlace --Maestro materiales
CLEAR it_link.
REFRESH it_link.

it_link-objecttype = 'MARA'.
it_link-objectkey  = '098010254'.
it_link-objectdescription = 'CADENA'.
APPEND it_link.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
  EXPORTING
    documentdata               = l_docu
*   HOSTNAME                   =
*   DOCBOMCHANGENUMBER         =
*   DOCBOMVALIDFROM            =
*   DOCBOMREVISIONLEVEL        =
*   CAD_MODE                   = ' '
*   PF_FTP_DEST                = ' '
*   PF_HTTP_DEST               = ' '
 IMPORTING
*   documenttype               = l_doctype
*   documentnumber             = l_docnumber
*   documentpart               = l_docpart
*   DOCUMENTVERSION            =
   return                     = l_return
 TABLES
*   CHARACTERISTICVALUES       =
*   CLASSALLOCATIONS           =
   documentdescriptions       = it_descrip
   objectlinks                = it_link
*   DOCUMENTSTRUCTURE          =
   documentfiles              = it_files
*   LONGTEXTS                  =
*   COMPONENTS                 =
          .

IF l_return-type CA 'EA'.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  ROLLBACK WORK.
  MESSAGE ID '26' TYPE 'I' NUMBER '000'
  WITH l_return-message.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
  MESSAGE 'DMS Creado correctamente' TYPE 'S'.
ENDIF.

VER  Modificar documento CV03N

miércoles, 15 de agosto de 2012

En un tablero de ajedrez de 4x4, Resolver el problema de colocar sobre este tablero el máximo número de reinas de tal manera que no se amenacen entre sí, sabiendo que una reina amenaza a cualquier otra que esté en su fila, columna o diagonal.


INCLUDE icons.

DATA: ok VALUE 0,
      s TYPE i VALUE 0.




SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit1 .

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE tit2 .
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (4) icono1 USER-COMMAND i1.
SELECTION-SCREEN PUSHBUTTON (4) icono2 USER-COMMAND i2.
SELECTION-SCREEN PUSHBUTTON (4) icono3 USER-COMMAND i3.
SELECTION-SCREEN PUSHBUTTON (4) icono4 USER-COMMAND i4.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (4) icono5 USER-COMMAND i5.
SELECTION-SCREEN PUSHBUTTON (4) icono6 USER-COMMAND i6.
SELECTION-SCREEN PUSHBUTTON (4) icono7 USER-COMMAND i7.
SELECTION-SCREEN PUSHBUTTON (4) icono8 USER-COMMAND i8.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (4) icono9 USER-COMMAND i9.
SELECTION-SCREEN PUSHBUTTON (4) icono10 USER-COMMAND i10.
SELECTION-SCREEN PUSHBUTTON (4) icono11 USER-COMMAND i11.
SELECTION-SCREEN PUSHBUTTON (4) icono12 USER-COMMAND i12.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (4) icono13 USER-COMMAND i13.
SELECTION-SCREEN PUSHBUTTON (4) icono14 USER-COMMAND i14.
SELECTION-SCREEN PUSHBUTTON (4) icono15 USER-COMMAND i15.
SELECTION-SCREEN PUSHBUTTON (4) icono16 USER-COMMAND i16.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (10) verifi USER-COMMAND ver.
SELECTION-SCREEN PUSHBUTTON (7) iniciar USER-COMMAND ini.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN.

  IF icono1 = 'X' OR icono2 = 'X'.
    PERFORM limpiar_botones.
  ELSE.
    CASE sy-ucomm.
      WHEN 'I1'.
        icono1 = '@RD@'.
      WHEN 'I2'.
        icono2 = '@RD@'.
      WHEN 'I3'.
        icono3 = '@RD@'.
      WHEN 'I4'.
        icono4 = '@RD@'.
      WHEN 'I5'.
        icono5 = '@RD@'.
      WHEN 'I6'.
        icono6 = '@RD@'.
      WHEN 'I7'.
        icono7 = '@RD@'.
      WHEN 'I8'.
        icono8 = '@RD@'.
      WHEN 'I9'.
        icono9 = '@RD@'.
      WHEN 'I10'.
        icono10 = '@RD@'.
      WHEN 'I11'.
        icono11 = '@RD@'.
      WHEN 'I12'.
        icono12 = '@RD@'.
      WHEN 'I13'.
        icono13 = '@RD@'.
      WHEN 'I14'.
        icono14 = '@RD@'.
      WHEN 'I15'.
        icono15 = '@RD@'.
      WHEN 'I16'.
        icono16 = '@RD@'.
      WHEN 'INI'.
        PERFORM limpiar_botones.
      WHEN 'VER'.
        PERFORM verificar.
    ENDCASE.
  ENDIF.

INITIALIZATION.
  MOVE : 'Tablero de ajedrez de 4x4.'   TO tit1.
  MOVE : 'Resolver el problema de colocar sobre este tablero el máximo número de reinas.'   TO tit2.
  iniciar = 'Iniciar'.
  verifi = 'Confirmar'.
  SET CURSOR FIELD 'INICIAR'.
  PERFORM limpiar_botones.

*&---------------------------------------------------------------------*
*&      Form  limpiar_botones
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM limpiar_botones.
  icono1 = ' '.
  icono2 = ' '.
  icono3 = ' '.
  icono4 = ' '.
  icono5 = ' '.
  icono6 = ' '.
  icono7 = ' '.
  icono8 = ' '.
  icono9 = ' '.
  icono10 = ' '.
  icono11 = ' '.
  icono12 = ' '.
  icono13 = ' '.
  icono14 = ' '.
  icono15 = ' '.
  icono16 = ' '.
  ok = 0.
  s = 0.
ENDFORM.                    "limpiar_botones

*&---------------------------------------------------------------------*
*&      Form  verificar
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM verificar .
  IF icono1 = '@RD@'.
    IF icono6 NE ' ' OR icono11 NE ' ' OR icono16 NE ' '
      OR icono2 NE ' ' OR icono3 NE ' ' OR icono4 NE ' '
      OR icono5 NE ' ' OR icono9 NE ' ' OR icono13 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.
  IF icono2 = '@RD@'.
    IF icono1 NE ' ' OR icono3 NE ' ' OR icono4 NE ' '
      OR icono6 NE ' ' OR icono10 NE ' ' OR icono14 NE ' '
      OR icono5 NE ' ' OR icono7 NE ' ' OR icono12 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono3 = '@RD@'.
    IF icono1 NE ' ' OR icono2 NE ' ' OR icono4 NE ' '
      OR icono7 NE ' ' OR icono11 NE ' ' OR icono15 NE ' '
      OR icono8 NE ' ' OR icono6 NE ' ' OR icono9 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono4 = '@RD@'.
    IF icono1 NE ' ' OR icono3 NE ' ' OR icono8 NE ' '
      OR icono12 NE ' ' OR icono16 NE ' ' OR icono7 NE ' '
      OR icono10 NE ' ' OR icono13 NE ' ' OR icono2 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono5 = '@RD@'.
    IF icono1 NE ' ' OR icono9 NE ' ' OR icono13 NE ' '
      OR icono6 NE ' ' OR icono8 NE ' ' OR icono2 NE ' '
      OR icono10 NE ' ' OR icono7 NE ' ' OR icono15 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono6 = '@RD@'.
    IF icono5 NE ' ' OR icono7 NE ' ' OR icono8 NE ' '
      OR icono2 NE ' ' OR icono10 NE ' ' OR icono14 NE ' '
      OR icono9 NE ' ' OR icono3 NE ' ' OR icono1 NE ' ' OR icono11 NE ' ' OR icono16 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono7 = '@RD@'.
    IF icono3 NE ' ' OR icono11 NE ' ' OR icono15 NE ' '
      OR icono5 NE ' ' OR icono6 NE ' ' OR icono8 NE ' '
      OR icono10 NE ' ' OR icono13 NE ' ' OR icono4 NE ' ' OR icono2 NE ' ' OR icono12 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono8 = '@RD@'.
    IF icono4 NE ' ' OR icono12 NE ' ' OR icono16 NE ' '
      OR icono5 NE ' ' OR icono6 NE ' ' OR icono7 NE ' '
      OR icono14 NE ' ' OR icono11 NE ' ' OR icono3 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono9 = '@RD@'.
    IF icono1 NE ' ' OR icono5 NE ' ' OR icono13 NE ' '
      OR icono10 NE ' ' OR icono11 NE ' ' OR icono12 NE ' '
      OR icono14 NE ' ' OR icono6 NE ' ' OR icono3 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono10 = '@RD@'.
    IF icono2 NE ' ' OR icono6 NE ' ' OR icono14 NE ' '
      OR icono9 NE ' ' OR icono11 NE ' ' OR icono12 NE ' '
      OR icono5 NE ' ' OR icono15 NE ' ' OR icono7 NE ' '
      OR icono14 NE ' ' OR icono13 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono11 = '@RD@'.
    IF icono9 NE ' ' OR icono10 NE ' ' OR icono12 NE ' '
      OR icono3 NE ' ' OR icono7 NE ' ' OR icono15 NE ' '
      OR icono1 NE ' ' OR icono6 NE ' ' OR icono16 NE ' '
      OR icono14 NE ' ' OR icono8 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono12 = '@RD@'.
    IF icono9 NE ' ' OR icono10 NE ' ' OR icono11 NE ' '
      OR icono16 NE ' ' OR icono6 NE ' ' OR icono8 NE ' '
      OR icono4 NE ' ' OR icono15 NE ' ' OR icono2 NE ' ' OR icono7 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono13 = '@RD@'.
    IF icono1 NE ' ' OR icono5 NE ' ' OR icono9 NE ' '
      OR icono14 NE ' ' OR icono15 NE ' ' OR icono16 NE ' '
      OR icono10 NE ' ' OR icono7 NE ' ' OR icono4 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono14 = '@RD@'.
    IF icono13 NE ' ' OR icono15 NE ' ' OR icono16 NE ' '
      OR icono10 NE ' ' OR icono6 NE ' ' OR icono2 NE ' '
      OR icono9 NE ' ' OR icono11 NE ' ' OR icono8 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono15 = '@RD@'.
    IF icono13 NE ' ' OR icono14 NE ' ' OR icono16 NE ' '
      OR icono11 NE ' ' OR icono3 NE ' ' OR icono7 NE ' '
      OR icono12 NE ' ' OR icono10 NE ' ' OR icono5 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF icono16 = '@RD@'.
    IF icono13 NE ' ' OR icono14 NE ' ' OR icono15 NE ' '
      OR icono12 NE ' ' OR icono8 NE ' ' OR icono4 NE ' '
      OR icono1 NE ' ' OR icono6 NE ' ' OR icono11 NE ' '.
      ok = 1.
    ELSE.
      s = s + 1.
    ENDIF.
  ENDIF.

  IF ok = 0.
    IF s = 4.
      MESSAGE 'Gano ' TYPE 'S'.
    ELSEIF s <= 3.
      MESSAGE 'pueden haber mas reinas' TYPE 'S'.
      PERFORM x.
    ENDIF.
  ELSE.
    MESSAGE 'Hay alguna reina mal ubicaca' TYPE 'S'.
    PERFORM x.
    s = 0.
    ok = 0.
  ENDIF.

ENDFORM.                    "verificar


*&---------------------------------------------------------------------*
*&      Form  X
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM x .
  IF icono1 NE '@RD@'.
    icono1 = 'X'.
  ENDIF.

  IF icono2 NE '@RD@'.
    icono2 = 'X'.
  ENDIF.

  IF icono3 NE '@RD@'.
    icono3 = 'X'.
  ENDIF.

  IF icono4 NE '@RD@'.
    icono4 = 'X'.
  ENDIF.

  IF icono5 NE '@RD@'.
    icono5 = 'X'.
  ENDIF.

  IF icono6 NE '@RD@'.
    icono6 = 'X'.
  ENDIF.

  IF icono7 NE '@RD@'.
    icono7 = 'X'.
  ENDIF.

  IF icono8 NE '@RD@'.
    icono8 = 'X'.
  ENDIF.

  IF icono9 NE '@RD@'.
    icono9 = 'X'.
  ENDIF.

  IF icono10 NE '@RD@'.
    icono10 = 'X'.
  ENDIF.

  IF icono11 NE '@RD@'.
    icono11 = 'X'.
  ENDIF.

  IF icono12 NE '@RD@'.
    icono12 = 'X'.
  ENDIF.

  IF icono13 NE '@RD@'.
    icono13 = 'X'.
  ENDIF.

  IF icono14 NE '@RD@'.
    icono14 = 'X'.
  ENDIF.

  IF icono15 NE '@RD@'.
    icono15 = 'X'.
  ENDIF.

  IF icono16 NE '@RD@'.
    icono16 = 'X'.
  ENDIF.

ENDFORM.                    "X

jueves, 9 de agosto de 2012

Error en Layout Screen Painter SAP

Cuando nos conectamos desde la red WAN el Screen Painter de SAP no se muestra normal. este se ve como si la opcion de Screen Painter grafico estubiera inactiva (Utilidades-opciones -- Screen Painter).



Se ve de esta forma. Para corregir este error hay que habilitar el puerto de la Screen Painter 3300 en el router.


Configurar Puerto para Screen Painter en Router NETGEAR. Buscamos segun el router donde se configuran los puertos, en este caso es en la opcion Port Forwarding/Port Triggering. Dejamos la opcion Activa Port Forwarding Vemos que la conexion al Sap ya esta listo con el puerto 3200 y con la IP de la maquina.



Damos click en add custom service.




y creamos el puerto como se ve en la imagen agregando el 3300 y la IP de la maquina. Listo cuando volvamos a ejecutar el Screen aparece de forma correcta.


ok.