lunes, 18 de noviembre de 2013

Visualizar variante de un JOB


En la SM37.



Se presiona PASO.


Se presiona el menú Pasar a -> Variante:

Por ultimo Presionas el Boton Valores.

espero les sea de utilidad

martes, 22 de octubre de 2013

Correo HTML, con Tabla



FORM enviar_mail_aviso.
  MESSAGE s499 WITH 'Envio Mail'.
* Data Declaration
  DATA: wa_docdata TYPE sodocchgi1,
        wa_objpack TYPE sopcklsti1 ,
        it_objpack TYPE TABLE OF sopcklsti1,
        wa_objtxt  TYPE solisti1,
        it_objtxt  TYPE TABLE OF solisti1,
        wa_reclist TYPE somlreci1,
        it_reclist TYPE TABLE OF somlreci1.
  DATA: tab_lines  TYPE i.
* Cabecera
  wa_objtxt = '<SPAN style="font-family:arial;font-size:10.5pt;color:black">'.
  APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = 'Estimados: <BR>'.
  APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = 'Los siguientes colaboradores se encuentran desvinculados de'.
  APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = 'la compañía. Favor informar deudas pendientes a la brevedad.<BR><BR><BR>'.
  APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<SPAN>'.
  APPEND wa_objtxt TO it_objtxt.
* Detalle
  wa_objtxt = '<table border=1 cellspacing=0 cellpadding=2 bordercolor="666666"><tr>'.APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<th scope="col" bgcolor="666666">Cod. Personal</th>'.APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<th scope="col" bgcolor="666666">Nombre</th>'.APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<th scope="col" bgcolor="666666">DNI</th>'.APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<th scope="col" bgcolor="666666">Fecha Alta</th>'.APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<th scope="col" bgcolor="666666">Fecha Baja</th>'.APPEND wa_objtxt TO it_objtxt.
  wa_objtxt = '<th scope="col" bgcolor="666666">Div. Personal</th>'.APPEND wa_objtxt TO it_objtxt.
  "Nueva Fila
  LOOP AT it_salida.
    wa_objtxt = '</tr><tr>'.APPEND wa_objtxt TO it_objtxt.
    CONCATENATE '<td>' it_salida-pernr '</td>' INTO wa_objtxt.APPEND wa_objtxt TO it_objtxt.
    CONCATENATE '<td>' it_salida-fname '</td>' INTO wa_objtxt.APPEND wa_objtxt TO it_objtxt.
    CONCATENATE '<td>' it_salida-perid '</td>' INTO wa_objtxt.APPEND wa_objtxt TO it_objtxt.
    CONCATENATE '<td>' it_salida-f_alta+6(2'.'
                       it_salida-f_alta+4(2'.'
                       it_salida-f_alta+0(4''
                '</td>' INTO wa_objtxt.
    APPEND wa_objtxt TO it_objtxt.
    CONCATENATE '<td>' it_salida-f_baja+6(2'.'
                       it_salida-f_baja+4(2'.'
                       it_salida-f_baja+0(4''
                '</td>' INTO wa_objtxt.
    APPEND wa_objtxt TO it_objtxt.
    CONCATENATE '<td>' it_salida-werks '</td>' INTO wa_objtxt.APPEND wa_objtxt TO it_objtxt.
  ENDLOOP.
  "Fin de la Tabla
  wa_objtxt = '</tr></table>'.APPEND wa_objtxt TO it_objtxt.
*
  DESCRIBE TABLE it_objtxt LINES tab_lines.
  READ TABLE it_objtxt INTO wa_objtxt INDEX tab_lines.
  wa_docdata-obj_name  = 'Notificación'.
  wa_docdata-obj_descr = 'Nuevas Desvinculaciones'.
  wa_docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( wa_objtxt ).
  CLEAR wa_objpack-transf_bin.
  wa_objpack-head_start = 1.
  wa_objpack-head_num = 0.
  wa_objpack-body_start = 1.
  wa_objpack-body_num = tab_lines.
  wa_objpack-doc_type = 'HTM'.
  APPEND wa_objpack TO it_objpack.
*
*create receiver list
  "- Inbox SAP
* wa_reclist-receiver = SY-UNAME.
* wa_reclist-rec_type = 'B'.
  "- Correo Externo
  wa_reclist-receiver = 'abaperohr@gmail.com'.
  wa_reclist-rec_type = 'U'.
  APPEND wa_reclist TO it_reclist.
*send_mail .
  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      document_data              = wa_docdata
      put_in_outbox              = 'X'"' '
      commit_work                = 'X'
    TABLES
      packing_list               = it_objpack
      contents_txt               = it_objtxt
      receivers                  = it_reclist
    EXCEPTIONS
      too_many_receivers         = 1
      document_not_sent          = 2
      document_type_not_exist    = 3
      operation_no_authorization = 4
      parameter_error            = 5
      x_error                    = 6
      enqueue_error              = 7
      OTHERS                     = 8.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
    WITH sy-msgv1.
  ELSE.
    WRITE : / 'Mail sent to', sy-uname.
  ENDIF.
ENDFORM" send_mail
 
y como siempre, si existe una forma más fácil me avisan.

jueves, 3 de octubre de 2013

Diferencia de horas entre Fechas

acá les dejo un ejemplo muy simple:

Function z_test.
*"----------------------------------------------------------------------
*"*"Interfase local
*"  IMPORTING
*"     REFERENCE(FECHA_INI) TYPE  DATUM DEFAULT '04022012'
*"     REFERENCE(HORA_INI) TYPE  UZEIT DEFAULT '162200'
*"     REFERENCE(FECHA_FIN) TYPE  DATUM DEFAULT '05022012'
*"     REFERENCE(HORA_FIN) TYPE  UZEIT DEFAULT '010000'
*"  EXPORTING
*"     VALUE(E_TDIFF) LIKE  TVRO-FAHZTD
*"     VALUE(E_DATE2_EARLY) LIKE  RV56A-SELKZ
*"----------------------------------------------------------------------
  call function 'SD_CALC_DURATION_FROM_DATETIME'
    exporting
      i_date1          = fecha_ini
      i_time1          = hora_ini
      i_date2          = fecha_fin
      i_time2          = hora_fin
    importing
      e_tdiff          = e_tdiff
      e_date2_early    = e_date2_early
    exceptions
      invalid_datetime = 1
      others           = 2.
endfunction.





viernes, 21 de junio de 2013

Ayuda de Búsqueda, tipo parameters en Dynpro



Ayuda de Búsqueda, tipo parameters en Dynpro
Lo primero es insertan en la Dynpro los elementos, en este caso
V_TRFAR [Campo], P_TRFAR [Botón con Icono] .
V_TRFGB [Campo], P_TRFGB [Botón con Icono] .
Visualmente quedará así.
La Función que utilizare es la siguiente: 'COMPLEX_SELECTIONS_DIALOG'
Ahora la Lógica:
Para no generar confusión, solo les mostrare para un caso.
*&---------------------------------------------------------------------*
*&  Include           DY0000
*&---------------------------------------------------------------------*
data : begin of it_dynpfields occurs 3.
        include structure dynpread.
data : end of it_dynpfields.

tables: p0008.
ranges: r_trfar for  p0008-trfar. “Range uso interno
data:   v_trfar like p0008-trfar. “Campo de la Dynpro
data:   p_trfar(30type c.       “Boton de la Dynpro
*----------------------------------------------------------------------
module get_cursor_v_trfar input. “Para el Campo, HELP

  refresh it_dynpfields.
  clear   it_dynpfields.

  move 'V_TRFAR' to it_dynpfields-fieldname.
  append it_dynpfields.
  clear  it_dynpfields.

  call function 'DYNP_VALUES_READ'
    exporting
      dyname               = sy-cprog
      dynumb               = sy-dynnr
      translate_to_upper   = 'X'
    tables
      dynpfields           = it_dynpfields
    exceptions
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      invalid_parameter    = 7
      undefind_error       = 8
      double_conversion    = 9
      stepl_not_found      = 10
      others               = 11.
  if sy-subrc = 0.
    read table it_dynpfields with key fieldname = 'V_TFAR'.
    if sy-subrc = 0.
      v_trfar = it_dynpfields-fieldvalue.
    endif.
  endif.
  perform get_multiple_trfar.
endmodule.                    
*----------------------------------------------------------------------
form get_multiple_trfar . “Para el Campo, HELP con Range
* Dynamically holding Field name
  field-symbols: <fst> type standard table.
  if  r_trfar[] is initial.
    if not v_trfar is initial.
      r_trfar-sign = 'I'.
      r_trfar-option = 'EQ'.
      r_trfar-low = v_trfar.
      append r_trfar.
      clear  r_trfar.
    endif.
  endif.
*
  assign r_trfar[] to <fst>.
*
  call function 'COMPLEX_SELECTIONS_DIALOG'
   exporting
     title               = 'Select Multiple Value'(059)
     text                = 'Finish Group'(058)
     signed              = 'X'
     lower_case          = ' '
     no_interval_check   = ' ' "'X'
     just_display        = ' '
     just_incl           = ' ' "'X'
     EXCLUDED_OPTIONS    ' ' 
     DESCRIPTION         = ' ' 
     HELP_FIELD          = ' ' 
     search_help         = 'ZH_T510G'    "Ayuda descrita en se11 (F4)
*    TAB_AND_FIELD       = tab_and_field "Ref.ocupa help de tabla-campo
   tables
     range               = <fst>
   exceptions
     no_range_tab        = 1
     cancelled           = 2
     internal_error      = 3
     invalid_fieldname   = 4
     others              = 5.
 *
  if sy-subrc = 0.
    read table r_trfar index 1.
    if sy-subrc = 0.
      v_trfar = r_trfar-low.
    else.
      refresh it_dynpfields.
      clear   it_dynpfields.
      move 'V_TRFAR' to it_dynpfields-fieldname.
      append it_dynpfields.
      clear  it_dynpfields.

      call function 'DYNP_VALUES_UPDATE' “Act. Directa a la Dynpro
        exporting
          dyname               = sy-cprog
          dynumb               = sy-dynnr
        tables
          dynpfields           = it_dynpfields
        exceptions
          invalid_abapworkarea = 1
          invalid_dynprofield  = 2
          invalid_dynproname   = 3
          invalid_dynpronummer = 4
          invalid_request      = 5
          no_fielddescription  = 6
          undefind_error       = 7
          others               = 8.
    endif.
  endif.
  perform set_icons. “Ajuste del icono
endform.                    
*----------------------------------------------------------------------
form set_icons. “Ajuste del icono
  refresh it_dynpfields.
  clear   it_dynpfields.
* defino el icono
* Esto funciona si el botón está definido solo como salida
*   '@1F@' "ICON_ENTER_MORE
*   '@1E@' "ICON_DISPLAY_MORE
  describe table  r_trfar lines sy-tfill.
  if ( sy-tfill > 1 ).
    p_trfar = '@1E@'"ICON_DISPLAY_MORE
  else.
    p_trfar = '@1F@'"ICON_ENTER_MORE
  endif.
  move 'P_TRFAR' to it_dynpfields-fieldname.
  move  p_trfar  to it_dynpfields-fieldvalue.
  append it_dynpfields.
  clear  it_dynpfields.
*
  call function 'DYNP_VALUES_UPDATE' “Act. Directa a la Dynpro
    exporting
      dyname               = sy-cprog
      dynumb               = sy-dynnr
    tables
      dynpfields           = it_dynpfields
    exceptions
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      undefind_error       = 7
      others               = 8.
endform.                    "set_icons
*&---------------------------------------------------------------------*
*&      Module  STATUS_0000  OUTPUT
*&---------------------------------------------------------------------*
module convert_trfar output.
* Se procede a componer los ranges r_trfar
* ya que están guardados como string
* mido el largo del texto para setear el do().
  data: l_leng type i, l_regi type i, l_seg type i.
  data: l_trfar type string.
*
  clear: r_trfar.    refresh: r_trfar.
  clear: l_trfar.
    l_leng  = l_regi = l_seg = 0.
* TRFAR
    l_trfar = [Tabla]-d_trfar. “donde se guarda el range como texto
    l_leng  = strlen( l_trfar ).
    l_regi  = l_leng / 7" ABBCCDD,...
    do l_regi times.
      r_trfar-sign   = l_trfar+l_seg(1). add 1 to l_seg.
      r_trfar-option = l_trfar+l_seg(2). add 2 to l_seg.
      r_trfar-low    = l_trfar+l_seg(2). add 2 to l_seg.
      if ( l_leng > l_seg ).
        r_trfar-high = l_trfar+l_seg(2). add 2 to l_seg.
      endif.
      append r_trfar. “restauro el range
    enddo.
* defino el icono
  perform set_icons.
endmodule.                    
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0000  INPUT
*&---------------------------------------------------------------------*
module uc_trfar_trfgb input. “convierto el Range en texto
  data: t_dynpfields type table of dynpread,
        r_dynpfields type dynpread.
  data:  l_str01 type string .
  clear: l_str01.
*  if ( ok_code eq 'SAVE' ). 
* Se procede a descomponer el range r_trfar.
* ya que deberan ser guardados como string
  if not ( r_trfar is initial ).
    loop at r_trfar.
      concatenate l_str01
                  r_trfar-sign                              "# 1 X
                  r_trfar-option                            "# 2 XX
                  r_trfar-low                               "# 2 XX
                  r_trfar-high                              "# 2 XX
             into l_str01 respecting blanks.
    endloop.
    [Tabla]-d_trfar = l_str01.
  else.
    [Tabla]-d_trfar = ''.
    v_trfar = ''.
  endif.
*
case ok_code. “ Para el Push del botón
    when 'P_TRFAR'.
      perform get_multiple_trfar .
endcase.

endmodule.                    
*&---------------------------------------------------------------------*
Dympro 0000
*&---------------------------------------------------------------------*
process before output.
  module convert_trfar_trfgb.
 
process after input.
module uc_trfar_trfgb.
process on value-request .
  field v_trfar module get_cursor_v_trfar. 
  field v_trfgb module get_cursor_v_trfgb. 
*&---------------------------------------------------------------------*


Estoy consciente de que no se ve muy fácil, pero les recomiendo que intenten implementarlo, es de mucha utilidad.