viernes, 2 de octubre de 2015

Para bajar gráficos de la se78

*&---------------------------------------------------------------------*
*& Report  Z_EXPORT_GRAPHIC_FROM_SE78                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&   This program exports logos from SE78 to a pc file in .bmp format  *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  z_export_graphic_from_se78    .

*
*-----------------------------------------------------------------------
* Description: This program extracts graphic logos from the BDS and
*              saves it as a .bmp file on the pc.  Transaction SE78
*              does not provide a way to export logos.
* Author     : Keerthi Hiremath
* Date       : 15JAN2003
* Request    :
* Design doc :
*
*
*-----------------------------------------------------------------------
*                 M O D I F I C A T I O N    L O G
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
*@DAT                         D A T A
*-----------------------------------------------------------------------
TYPE-POOLS: sbdst .
DATA : git_content TYPE sbdst_content.
DATA : git_rawdata TYPE w3mime OCCURS 0,
       g_bitmaptypeout TYPE c.
DATA : BEGIN OF git_bitmap OCCURS 0,
             line(1000),
       END   OF git_bitmap.
DATA : g_bytecount TYPE i.
*-----------------------------------------------------------------------
*@SSL             S E L E C T I O N   S C R E E N
*-----------------------------------------------------------------------
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
PARAMETERS      : p_obj LIKE stxbitmaps-tdobject DEFAULT 'ZOGLGRPOBJ',
                  p_nam LIKE stxbitmaps-tdname,
                  p_id  LIKE stxbitmaps-tdid DEFAULT 'ZC',
                  p_ref LIKE stxbitmaps-tdbtype DEFAULT 'BMON'.
SELECTION-SCREEN: END   OF BLOCK b01.
SELECTION-SCREEN: BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
PARAMETERS      : p_file LIKE rlgrap-filename.
SELECTION-SCREEN: END   OF BLOCK b02.
*-----------------------------------------------------------------------
*@INI                 I N I T I A L I Z A T I O N.
*-----------------------------------------------------------------------
INITIALIZATION.
*

*-----------------------------------------------------------------------
*@SOS             S T A R T   O F   S E L E C T I O N
*-----------------------------------------------------------------------
START-OF-SELECTION.
*
  PERFORM sapscript_get_graphic_bds.
  PERFORM sapscript_convert_bitmap.
  PERFORM ws_download.
*
*-----------------------------------------------------------------------
*@EOS                E N D   O F   S E L E C T I O N
*-----------------------------------------------------------------------
END-OF-SELECTION.
*

*-----------------------------------------------------------------------
*@TOP                   T O P   O F   P A G E
*-----------------------------------------------------------------------
TOP-OF-PAGE.
*

*-----------------------------------------------------------------------
*               A T   S E L E C T I O N   S C R E E N
*-----------------------------------------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_nam.
*
  DATA: l_return TYPE i.
  RANGES: r_obj FOR stxbitmaps-tdobject.
  DATA: l_bitmaps TYPE TABLE OF stxbitmaps WITH HEADER LINE.
  DATA: lit_scrfields TYPE TABLE OF dynpread WITH HEADER LINE.
*
  r_obj-sign = 'I'.
  r_obj-option = 'EQ'.
  r_obj-low = 'ZOGLGRPOBJ'.
  APPEND r_obj.
*
  CALL FUNCTION 'SAPSCRIPT_SEARCH_GRAPHIC_BDS'
    EXPORTING
      selection_screen         = 'X'
      select_entry             = 'X'
      selection_show           = 'X'
    IMPORTING
      e_object                 = p_obj
      e_id                     = p_id
      e_name                   = p_nam
      e_btype                  = p_ref
    TABLES
      t_objects                = r_obj
*    T_IDS                    = R_IDS
*    T_BTYPES                 = R_REFS
      t_selections             = l_bitmaps
    EXCEPTIONS
      nothing_found            = 1
      selection_canceled       = 2
      internal_error           = 3
      OTHERS                   = 4
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE..
    lit_scrfields-fieldname = 'P_ID'.
    lit_scrfields-fieldvalue = p_id.
    APPEND lit_scrfields.
    CALL FUNCTION 'DYNP_VALUES_UPDATE'
      EXPORTING
        dyname                     = 'Z_EXPORT_GRAPHIC_FROM_SE78'
        dynumb                     = '1000'
      TABLES
        dynpfields                 = lit_scrfields
*     EXCEPTIONS
*       INVALID_ABAPWORKAREA       = 1
*       INVALID_DYNPROFIELD        = 2
*       INVALID_DYNPRONAME         = 3
*       INVALID_DYNPRONUMMER       = 4
*       INVALID_REQUEST            = 5
*       NO_FIELDDESCRIPTION        = 6
*       UNDEFIND_ERROR             = 7
*       OTHERS                     = 8
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  ENDIF.

*
*-----------------------------------------------------------------------
*@FOR                          F O R M S
*-----------------------------------------------------------------------
*
*
*&---------------------------------------------------------------------*
*&      Form  SAPSCRIPT_GET_GRAPHIC_BDS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sapscript_get_graphic_bds.
*
  CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
       EXPORTING
            i_object       = p_obj
            i_name         = p_nam
            i_id           = p_id
            i_btype        = p_ref
       IMPORTING
            e_bytecount    = g_bytecount
       TABLES
            content        = git_content
       EXCEPTIONS
            not_found      = 1
            bds_get_failed = 2
            bds_no_content = 3
            OTHERS         = 4.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*
ENDFORM.                    " SAPSCRIPT_GET_GRAPHIC_BDS

*&---------------------------------------------------------------------*
*&      Form  SAPSCRIPT_CONVERT_BITMAP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sapscript_convert_bitmap.
*                                                assign
  CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP '
       EXPORTING
            old_format               = 'BDS'
            new_format               = 'BMP'
            bitmap_file_bytecount_in = g_bytecount
            itf_bitmap_type_in       = '*'
       IMPORTING
            bitmap_file_bytecount    = g_bytecount
            itf_bitmap_type_out      = g_bitmaptypeout
       TABLES
            bitmap_file              = git_rawdata
            bds_bitmap_file          = git_content
       EXCEPTIONS
            no_bitmap_file           = 1
            format_not_supported     = 2
            bitmap_file_not_type_x   = 3
            no_bmp_file              = 4
            bmperr_invalid_format    = 5
            bmperr_no_colortable     = 6
            bmperr_unsup_compression = 7
            bmperr_corrupt_rle_data  = 8
            bmperr_eof               = 9
            bdserr_invalid_format    = 10
            bdserr_eof               = 11
            OTHERS                   = 12.
  IF sy-subrc <> 0.
*   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*
ENDFORM.                    " SAPSCRIPT_CONVERT_BITMAP

*&---------------------------------------------------------------------*
*&      Form  WS_DOWNLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ws_download.
*
  CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
            bin_filesize            = g_bytecount
            filename                = p_file
            filetype                = 'BIN'
       TABLES
            data_tab                = git_rawdata
       EXCEPTIONS
            file_open_error         = 1
            file_write_error        = 2
            invalid_filesize        = 3
            invalid_type            = 4
            no_batch                = 5
            unknown_error           = 6
            invalid_table_width     = 7
            gui_refuse_filetransfer = 8
            customer_error          = 9
            OTHERS                  = 10.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*
ENDFORM.                    " WS_DOWNLOAD

viernes, 10 de abril de 2015

Debuguear un proceso de fondo (un Job) activo o terminado

Job activo: Ir a la transacción SM50. Seleccionar job e ir a Menú-> Programa/modo -> Programa->Debugging

Job terminado o cancelado: Colocar un break point en el programa. Ir a la SM37 y seleccionar el job terminado o cancelado. Indicar JDBG en la línea de comandos y pulsar intro. Al entrar en el modo de debugging, pulsar F8 y llegaremos al break point.

lunes, 23 de marzo de 2015

Condición <> INITIAL en Smartform

Cuando queramos que un nodo de un Smartform no aparezca cuando el texto que muestra esté en blanco, las opciones <> '' y <> INITIAL no funcionan.
En su lugar, debemos indicar <> SPACE

martes, 17 de marzo de 2015

Manual de querys


Útil manual de querys

Manual Querys

Asignar orden de transporte a traducciones

Ejecutar la transacción SE63 y traducir los textos necesarios de los objetos a tratar.

Una vez realizada la traducción, ejecutar la transacción SLXT para crear una orden de transporte o añadir el transporte a una orden existente


Traducir mediante se63 sin el idioma instalado mediante debug

1 - Poner un break point en el módulo de función SCP_ALLOWED_LANGUAGES, linea 23.

if sy-subrc <> 0 or languages = space.

2 - Ejecutar la transacción SE63 con el idioma destino y clicar en el botón de editar.

3 - Cuando el programa se pare, comprobar los valores en la variable languages e introducir en la lista el que necesitamos.

4 - Presionando F8 podremos traducir el formulario a pesar de no tener el idioma destino instalado en el sistema. 

Impresión ZEBRA

Ver las siguientes notas:

179534 - Label printing using Zebra printers (SAPscript)
750002 - Support for Zebra label printers (ZPL2)

Para poder previsualizar este tipo de etiquetas podemos utilizar la web:

Se pone el texto obtenido en la impresión por pantalla (que podemos copiar con la transacción pdf!, sin /n ni /o ni nada) y pulsamos en "redraw".

Cargar fuente de Office en SAP

Para cargar una fuente de las de office en SAP, utilizar el report RSTXPDF2

Debuguear sapscript

Se debe de ejecutar el report RSTXDBUG para activar este tipo de debug

Bapi contabilización documento FI


datagwa_doc_header    like bapiache09 occurs with header line
    gt_curr           
like bapiaccr09 occurs with header line
    gt_accgl          
like bapiacgl09 occurs with header line
    gt_accountreceiva 
like bapiacar09 occurs with header line
    g_obj_type        
like bapiache09-obj_type,
    g_obj_key         
like bapiache09-obj_key,
    g_obj_sys         
like bapiache09-obj_sys,
    gt_accountpayable 
like bapiacap09 occurs with header line
    gt_acc_taxes      
like bapiactx09 occurs with header line,
    gt_return         
like bapiret2   occurs with header line.


call function 'BAPI_ACC_DOCUMENT_POST'
      
exporting
        documentheader    
gwa_doc_header “Datos de cabecera
      
importing
        obj_type          
g_obj_type
        obj_key           
g_obj_key    “Chequea que se rellene
        obj_sys           
g_obj_sys
      
tables
        accountgl         
gt_accgl     “Datos de cuentas de mayor
        accountreceivable 
gt_accountreceiva “Datos de cliente
        accountpayable    
gt_accountpayable “Datos de acreedor
        accounttax        
gt_acc_taxes      “Datos de IVA
        currencyamount    
gt_curr            “Importes (obligatorio)
        
return            lt_return.

    
read table lt_return
      
with key type 'E'.

    
if sy-subrc <> 0.
      
call function 'BAPI_TRANSACTION_COMMIT'
        
exporting
          
wait c_ok.
      p_subrc 
sy-subrc.
    
else.
      
call function 'BAPI_TRANSACTION_ROLLBACK'.
      p_subrc 
4.
    
endif.

Función para encontrar querys y usuarios de quickviews

Utilizar la función RSAQ_IMPORT_USERGROUP_CATALOG

Modificar contenido de tabla cuando no hay permisos de debug

Utilizaremos la función SE16N_INTERFACE

Obtener dirección de un interlocutor comercial de un documento de ventas

Buscar en la tabla VBPA el campo ADRNR de nuestro interlocutor comercial.

Ojo, utilizar funciones CONVERSION_EXIT_PARVW_INPUT y CONVERSION_EXIT_PARVW_OUTPUT

A - Luego llamar a la función ADDR_COMM_GET con este número y tabletype ADSMTP
El resultado lo tendremos en INF_ADR6-SMTP_ADDR

B - También se puede buscar directamente en la tabla ADR6 con ese número y la fecha actual >= date_from
Si queremos la dirección por defecto tomamos el de flgdefault = 'X'.
El resultado lo tenemos en el campo SMTP_ADDR

Popup con mensajes de exito o error

form log.

  
datawa_return type bapiret2_t with header line,
        p_command   
type char1,
        p_return    
type char1.

  
loop at gt_return into wa_return.

    
perform fw_inicializa_mensajes.

    
perform fw_registrar_message using wa_return-id " Clase de mensaje
                             wa_return
-type         " tipo
                             wa_return
-number       " num de msg en clase M
                             wa_return
-message_v1   " vars
                             wa_return
-message_v2
                             wa_return
-message_v3
                             wa_return
-message_v4.

  
endloop.

  
perform fw_mostrar_mensajes changing p_command
                                     p_return
.

  
perform fw_finaliza_mensajes.

endform.

**********************************************************

form fw_inicializa_mensajes .

  
call function 'MESSAGES_INITIALIZE'.

endform.                    " FW_INICIALIZA_MENSAJES

form fw_registrar_message  using value(p_msgid" Clase de mensaje
                             
value(p_msgtyp)     " tipo
                             
value(p_msgnr)      " num de msg en clase M
                             
value(p_msgv1)      " vars
                             
value(p_msgv2)
                             
value(p_msgv3)
                             
value(p_msgv4).


  
if sy-batch <> 'X'.
*   Sólo si el proceso no es en fondo
    
call function 'MESSAGE_STORE'
      
exporting
        arbgb                         
p_msgid
*        exception_if_not_active       = ' '
        msgty                         
p_msgtyp
        msgv1                         
p_msgv1
        msgv2                         
p_msgv2
        msgv3                         
p_msgv3
        msgv4                         
p_msgv4
        txtnr                         
p_msgnr
*        zeile                         = gl_posic_mess " l_posic
      
exceptions
        message_type_not_valid        
1
        not_active                    
2
        
others                        3.
  
else.
*   Si es en fondo se lanza el mensaje
    
dataaux_msgty like sy-msgty.
    
aux_msgty p_msgtyp.
    
if aux_msgty 'E' or aux_msgty 'A'.
      aux_msgty 
'I'.
    
endif.
    
message id p_msgid
          
type aux_msgty
        
number p_msgnr
          
with p_msgv1 p_msgv2 p_msgv3 p_msgv4.
  
endif.

endform.                    " FW_REGISTRAR_MESSAGE

form fw_mostrar_mensajes changing p_return p_command.

  datau_command type bal_s_excm.   clearu_commandp_returnp_command.
  call function 'MESSAGES_SHOW'     exporting       batch_list_type    'J' " J job, L spool, B spool y job       i_use_grid         'X'     importing       e_exit_command     u_command
    
    exceptions       inconsistent_range 1       no_messages        2       others             3.
  p_return sy-subrc.
  case 'X'.
    when u_command-back.       p_command 'B'.     when u_command-exit.       p_command 'E'.     when u_command-cancel.       p_command 'C'.     when u_command-continue.       p_command 'K'.     when u_command-external.       p_command 'X'.   endcase.


endform.                    " FW_MOSTRAR_MENSAJES


form fw_finaliza_mensajes .



  call function 'MESSAGES_INITIALIZE'
    
exceptions
      log_not_active       
1
      wrong_identification 
2
      
others               3.

  
call function 'MESSAGES_STOP'
    
exporting
      i_reset_messages  
'X'
    
exceptions
      a_message         
1
      e_message         
2
      w_message         
3
      i_message         
4
      s_message         
5
      deactivated_by_md 
6
      
others            7.

endform.                    " FW_FINALIZA_MENSAJES