Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Temas - oscar

Páginas: 1 [2] 3
16
Funciones / Adjunta archivos con 'SWU_OBJECT_PUBLISH'
« en: 31 de Octubre de 2007, 11:58:43 am »
Interesante función... con ella puedes adjuntar cualquier tipo de archivo, imagen, etc... a un documento de sap. Luego lo puedes descargar a tu PC, enviarlo por mail...  :o

Te genera un botón que se encuentra en la barra de titulo.

Y este es un pequeño programa para probarlo.
Código: [Seleccionar]
REPORT ZRICH_0001 .

parameters: p_check type c.

at selection-screen output.

  CALL FUNCTION 'SWU_OBJECT_PUBLISH'
    EXPORTING
      objtype                 = 'BUS2038'
      objkey                  = '1'
*     CREATOR                 = ' '
*     METHOD                  = ' '
*   TABLES
*     CONTAINER               =
   EXCEPTIONS
     OBJTYPE_NOT_FOUND       = 1
     OTHERS                  = 2.


start-of-selection.


17
Programación ABAP / MOVIDO: Buscamos Analistas Programadores
« en: 27 de Septiembre de 2007, 08:34:23 am »

18
Reports / Como descargar una imagen de la SE78
« en: 20 de Septiembre de 2007, 01:12:28 pm »
Alguna vez has intentado descargarte una imagen de la SE78 porque la habías perdido?  ???

Este en un programa que te permite bajar cualquier imagen que tengas, de SAP... a tu PC.  ;D



*&---------------------------------------------------------------------*
*& Report  ZRECUPERAR_IMAGEN_SE78
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zrecuperar_imagen_se78.

DATA: l_bytecount TYPE i,
      l_tdbtype LIKE stxbitmaps-tdbtype,
      l_content TYPE STANDARD TABLE OF bapiconten
      INITIAL SIZE 0.

DATA: graphic_size TYPE i.

DATA: BEGIN OF graphic_table OCCURS 0,
      line(255) TYPE x,
      END OF graphic_table.


DATA: btype LIKE  stxbitmaps-tdbtype.


SELECTION-SCREEN BEGIN OF BLOCK uno WITH FRAME TITLE text-001.
PARAMETERS: name_img LIKE stxbitmaps-tdname DEFAULT 'ENJOY',
            filename TYPE  string DEFAULT 'C:\Oscar\Imagen_recup.bmp'.

SELECTION-SCREEN SKIP.

PARAMETERS: p_bcol RADIOBUTTON GROUP rad1,
            p_bmon RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK uno.



IF p_bcol = 'X'.
  btype = 'BCOL'.
ELSE.
  btype = 'BMON'.
ENDIF.


CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
  EXPORTING
    i_object       = 'GRAPHICS'
    i_name         = name_img    " Nombre del Logo
    i_id           = 'BMAP'
    i_btype        = btype
  IMPORTING
    e_bytecount    = l_bytecount
  TABLES
    content        = l_content
  EXCEPTIONS
    not_found      = 1
    bds_get_failed = 2
    bds_no_content = 3
    OTHERS         = 4.


CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
  EXPORTING
    old_format               = 'BDS'
    new_format               = 'BMP'
    bitmap_file_bytecount_in = l_bytecount
  IMPORTING
    bitmap_file_bytecount    = graphic_size
  TABLES
    bds_bitmap_file          = l_content
    bitmap_file              = graphic_table
  EXCEPTIONS
    OTHERS                   = 1.



CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    bin_filesize = graphic_size
    filename     = filename
    filetype     = 'BIN'
  TABLES
    data_tab     = graphic_table.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.




19
Programación ABAP / MOVIDO: Recién Titulados para Plan de Carrera ABAP IV
« en: 05 de Septiembre de 2007, 06:31:56 pm »

20
Programación ABAP / MOVIDO: - ANALISTAS ABAP IV -
« en: 05 de Septiembre de 2007, 06:31:32 pm »

21
Lista todos los programas de un 'sy-langu' y crea una orden con todos ellos.




REPORT zbctrans LINE-SIZE 128 NO STANDARD PAGE HEADING.

* Data definition
TABLES: trdir, t002, e070, e071, e07t.
DATA: BEGIN OF itab OCCURS 0,
      prog LIKE rs38m-programm,
      text LIKE rs38m-repti,
      END OF itab.
DATA: BEGIN OF iout OCCURS 0,
      prog LIKE rs38m-programm,
      END OF iout.
DATA: BEGIN OF itext OCCURS 200.
        INCLUDE STRUCTURE textpool.
DATA: END OF itext.
* Table for the tasks created.
DATA: BEGIN OF tasks OCCURS 1.
        INCLUDE STRUCTURE e070.
DATA: END OF tasks.
* Table for the objects to insert in the order.
DATA: BEGIN OF t_e071 OCCURS 0.
        INCLUDE STRUCTURE e071.
DATA: END OF t_e071.
DATA: BEGIN OF t_e071k OCCURS 0.
        INCLUDE STRUCTURE e071k.
DATA: END OF t_e071k.
* Variables
DATA: answer,
      l_checkbox,
      l_prog LIKE rs38m-programm,
      ew_order LIKE e070,
      ev_order LIKE e070-trkorr,
      ev_task LIKE  e070-trkorr,
      v_subrc LIKE sy-subrc,
      color,
      checkbox.

* Selection screen.
SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE text-001.
SELECT-OPTIONS: reps FOR trdir-name,
                lang FOR t002-spras NO-EXTENSION NO INTERVALS
                                    OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 001.

* User input.
AT USER-COMMAND.
  CASE sy-ucomm.
* Create request.
    WHEN 'REQ'.
      PERFORM confirm USING text-005 text-006.
      IF answer = 'J'.
        PERFORM choice.
        PERFORM request.
        IF sy-subrc = 0.
          PERFORM ok.
        ELSE.
          v_subrc = sy-subrc.
          PERFORM error.
        ENDIF.
      ENDIF.
* Select all.
    WHEN 'SEL'.
      PERFORM select.
* Unselect all.
    WHEN 'UNS'.
      PERFORM unselect.
  ENDCASE.
* Process.
START-OF-SELECTION.
* Warning if the user tries to select standard programs.
  READ TABLE reps INDEX 1.
  IF reps-low(1) NE 'Z'.
    PERFORM confirm USING text-003 text-004.
  ENDIF.
  IF answer = 'J' OR reps-low(1) = 'Z'.
* We place the list of programs in the internal table.
    SELECT * FROM trdir WHERE name IN reps.
      MOVE trdir-name TO itab-prog.
      APPEND itab. CLEAR itab.
    ENDSELECT.
    READ TABLE lang INDEX 1.
    LOOP AT itab.
      READ TEXTPOOL itab-prog LANGUAGE lang-low INTO itext.
      LOOP AT itext WHERE id = 'R'.
        itab-text = itext-entry.
        MODIFY itab. CLEAR itab.
        EXIT.
      ENDLOOP.
      REFRESH itext. CLEAR itext.
    ENDLOOP.
* List output.
    SET PF-STATUS 'LIST'.
    ULINE.
    FORMAT COLOR 1 INTENSIFIED ON.
    WRITE: / sy-vline,
           4 text-010,
           15 text-011,
           128 sy-vline.
    ULINE.
    LOOP AT itab WHERE NOT text IS INITIAL.
      IF color = 'X'.
        CLEAR color.
        FORMAT COLOR 2 INTENSIFIED OFF.
      ELSE.
        color = 'X'.
        FORMAT COLOR 2 INTENSIFIED ON.
      ENDIF.
      WRITE: / sy-vline,
             2 checkbox AS CHECKBOX,
             4 itab-prog,
             15 itab-text,
             128 sy-vline.
    ENDLOOP.
    IF sy-subrc NE 0.
      FORMAT COLOR 6 INTENSIFIED OFF.
      WRITE: / sy-vline, 4 text-012, 128 sy-vline.
    ENDIF.
    ULINE.
  ENDIF.

*---------------------------------------------------------------------*
*       FORM CONFIRM                                                  *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  LINE1                                                         *
*  -->  LINE2                                                         *
*---------------------------------------------------------------------*

FORM confirm USING line1 line2.
  CLEAR answer.
  CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
    EXPORTING
      defaultoption = 'N'
      textline1     = line1
      textline2     = line2
      titel         = text-002
      start_column  = 25
      start_row     = 6
    IMPORTING
      answer        = answer
    EXCEPTIONS
      OTHERS        = 1.
ENDFORM.                    "CONFIRM

*---------------------------------------------------------------------*
*       FORM SELECT                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

FORM select.
  DO.
    READ LINE sy-index FIELD VALUE checkbox.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    MODIFY CURRENT LINE FIELD VALUE checkbox FROM 'X'.
  ENDDO.
ENDFORM.                    "SELECT

*---------------------------------------------------------------------*
*       FORM UNSELECT                                                 *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

FORM unselect.
  DO.
    READ LINE sy-index FIELD VALUE checkbox.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    MODIFY CURRENT LINE FIELD VALUE checkbox FROM ' '.
  ENDDO.
ENDFORM.                    "UNSELECT

*---------------------------------------------------------------------*
*       FORM CHOICE                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

FORM choice.
  REFRESH iout. CLEAR iout.
  DO.
    CLEAR: l_checkbox, l_prog.
    READ LINE sy-index FIELD VALUE checkbox INTO l_checkbox
                                   itab-prog INTO l_prog.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    IF l_checkbox = 'X'.
      MOVE l_prog TO iout-prog.
      APPEND iout. CLEAR iout.
    ENDIF.
  ENDDO.
ENDFORM.                    "CHOICE

*---------------------------------------------------------------------*
*       FORM REQUEST                                                  *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

FORM request.
* First we create the order.
  CALL FUNCTION 'TR_ORDER_CREATE'
    EXPORTING
      iv_start_column   = 1
      iv_start_row      = 8
      iv_client         = sy-mandt
      iv_new_order_type = 'A'
      iv_new_task_type  = 'X'
      iv_category       = 'SYST'
    IMPORTING
      ew_order          = ew_order
      ev_order          = ev_order
      ev_task           = ev_task
    TABLES
      tt_tasks          = tasks
    EXCEPTIONS
      no_authorization  = 1
      OTHERS            = 2.
* Set the order as transportable...
  ew_order-trfunction = 'K'.
  CALL FUNCTION 'TRINT_CHANGE_OF_ATTRIBUTES'
    EXPORTING
      is_e070           = ew_order
    EXCEPTIONS
      change_error      = 1
      e070_update_error = 2
      e070_not_filled   = 3
      OTHERS            = 4.
* ...and the task.
  READ TABLE tasks INDEX 1.
  tasks-trfunction = 'S'.
  CALL FUNCTION 'TRINT_CHANGE_OF_ATTRIBUTES'
    EXPORTING
      is_e070           = tasks
    EXCEPTIONS
      change_error      = 1
      e070_update_error = 2
      e070_not_filled   = 3
      OTHERS            = 4.
* Include the programs in the transference table.
  LOOP AT iout.
    MOVE: tasks-trkorr TO t_e071-trkorr,
          '999999' TO t_e071-as4pos,
          'LIMU' TO t_e071-pgmid,
          'REPT' TO t_e071-object,
          iout-prog TO t_e071-obj_name.
    APPEND t_e071. CLEAR t_e071.
  ENDLOOP.
* Insert the objects.
  SELECT SINGLE * FROM e070 WHERE trkorr = tasks-trkorr.
  SELECT SINGLE * FROM e07t WHERE trkorr = tasks-trkorr.
  CALL FUNCTION 'TRINT_MODIFY_COMM'
    EXPORTING
      wi_called_by_editor            = ' '
      wi_e070                        = e070
      wi_e07t                        = e07t
      wi_lock_sort_flag              = 'X'
      wi_save_user                   = ' '
      wi_sel_e071                    = 'X'
      wi_sel_e071k                   = ' '
      wi_sel_e07t                    = ' '
    TABLES
      wt_e071                        = t_e071
      wt_e071k                       = t_e071k
    EXCEPTIONS
      chosen_project_closed          = 1
      e070_insert_error              = 2
      e070_update_error              = 3
      e071k_insert_error             = 4
      e071k_update_error             = 5
      e071_insert_error              = 6
      e071_update_error              = 7
      e07t_insert_error              = 8
      e07t_update_error              = 9
      locked_entries                 = 10
      locked_object_not_deleted      = 11
      ordername_forbidden            = 12
      order_change_but_locked_object = 13
      order_released                 = 14
      order_user_locked              = 15
      tr_check_keysyntax_error       = 16
      no_authorization               = 17
      e070c_insert_error             = 18
      e070c_update_error             = 19
      wrong_client                   = 20
      unallowed_source_client        = 21
      unallowed_user                 = 22
      OTHERS                         = 23.
ENDFORM.                    "REQUEST

*---------------------------------------------------------------------*
*       FORM ok                                                       *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

FORM ok.
  CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
      titel = text-007
      txt1  = text-008
      txt2  = ' '.
ENDFORM.                    "ok

*---------------------------------------------------------------------*
*       FORM error                                                    *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

FORM error.
  CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
      titel = text-007
      txt1  = text-009
      txt2  = v_subrc.
ENDFORM.                    "error


22
Informes / Informe en ALV para ver los Balances de las Cuentas Generales.
« en: 27 de Agosto de 2007, 06:32:22 pm »
En este informe podemos ver los Balances de las Cuentas Generales, para ello utilizamos la BAPI BAPI_GL_GETGLACCPERIODBALANCES.

El Include ZALV lo podemos copiar de este mismo foro en el apartado de los Includes.


REPORT  zfi_bal_generaux.

************************************************************************
*  DEFINICION TABLAS, ESTRUCTURAS Y TIPOS                              *
************************************************************************


*--DEFINICION DE TABLAS DE SISTEMA
TABLES: bsad,       "Contabilidad: índice secundario para deudores
        glt0,       "Cifras movimientos reg.maestro ctas.mayor
        skb1,
        skat,
        t001,
        ska1.




*--DEFINICION DE TABLAS INTERNAS
*-- tabla de clientes

DATA: BEGIN OF i_cliente OCCURS 0,
    saknr LIKE skb1-saknr.
DATA: END OF i_cliente.

*-- tabla para ALV
DATA: BEGIN OF i_datos OCCURS 0,
    clase(10),
    debe      LIKE bsid-dmbtr,
    haber     LIKE bsid-dmbtr,
    saknr     LIKE skb1-saknr,
    name1     LIKE skat-txt20,
    dif_debe  LIKE bsid-dmbtr,
    dif_haber LIKE bsid-dmbtr,
    saldo     LIKE bsid-dmbtr,
      END OF i_datos.

DATA: BEGIN OF i_datos2 OCCURS 0,
    clase2(10),
    debe      LIKE bsid-dmbtr,
    haber     LIKE bsid-dmbtr,
    altkt     LIKE skb1-altkt,
    name2     LIKE skat-txt20,
    dif_debe  LIKE bsid-dmbtr,
    dif_haber LIKE bsid-dmbtr,
    saldo     LIKE bsid-dmbtr,
      END OF i_datos2.

DATA: i_datos_bilan   LIKE i_datos OCCURS 0 WITH HEADER LINE.
DATA: i_datos_gestion LIKE i_datos OCCURS 0 WITH HEADER LINE.

DATA: saldo   LIKE bsid-dmbtr.


DATA: gs_disvariant TYPE disvariant.

* Type Pool donde vienen definidas todas las estructuras y tablas
TYPE-POOLS: slis.

* Catálogo de campos: contiene la descripción de los campos de salida
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      alv_sort    TYPE slis_t_sortinfo_alv WITH HEADER LINE,
      alv_sort2   TYPE slis_t_sortinfo_alv WITH HEADER LINE.



INCLUDE zalv.

************************************************************************
*  DEFINICION DE PARAMETROS DE SELECCION                               *
************************************************************************


SELECTION-SCREEN BEGIN OF BLOCK uno WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS:     p_bukrs LIKE glt0-bukrs OBLIGATORY.   "Sociedad
SELECT-OPTIONS: s_saknr FOR skb1-saknr,               "Nº cuenta
*               s_budat FOR bsad-budat OBLIGATORY,    "Fecha contab.
                s_monat FOR bsad-monat OBLIGATORY.    "Mes contable
PARAMETERS:     p_gjahr LIKE bsad-gjahr OBLIGATORY.   "Ejerc. Contable
SELECTION-SCREEN END OF BLOCK uno.

SELECTION-SCREEN BEGIN OF BLOCK dos WITH FRAME TITLE text-200.
PARAMETERS: cta_alt AS CHECKBOX DEFAULT space.
SELECTION-SCREEN END OF BLOCK dos.




************************************************************************
*  DEFINICION DE VARIABLES                                             *
************************************************************************






************************************************************************
*                                                                      *
*                                                                      *
*                        T R A T A M I E N T O                         *
*                                                                      *
*                                                                      *
************************************************************************

*----------------------------------------------------------------------*
*     START-OF-SELECTION                                               *
*----------------------------------------------------------------------*

START-OF-SELECTION.
  PERFORM selecciona_datos.
  PERFORM procesa_datos.
  IF NOT cta_alt IS INITIAL.
    PERFORM ctaltern.
  ENDIF.

END-OF-SELECTION.
  PERFORM pinta.




************************************************************************
*                                                                      *
*                                                                      *
*                        S U B - R U T I N A S                         *
*                                                                      *
*                                                                      *
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  selecciona_datos
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM selecciona_datos .

  SELECT * APPENDING CORRESPONDING FIELDS OF TABLE i_cliente
                FROM skb1
               WHERE bukrs = p_bukrs
                 AND saknr IN s_saknr.

ENDFORM.                    " selecciona_datos

*&---------------------------------------------------------------------*
*&      Form  procesa_datos
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM procesa_datos .
  DATA: BEGIN OF i_items OCCURS 0.
          INCLUDE STRUCTURE bapi1028_4.
  DATA: END   OF i_items.

  DATA: companycode  LIKE bapi1028_0-comp_code,
        glacct       LIKE bapi1028_0-gl_account,
        fiscalyear   LIKE bapi1028_4-fisc_year,
        currencytype LIKE bapi1028_5-curr_type,
        date_from    LIKE bapi3007-from_date,
        date_to      LIKE bapi3007-to_date,
        v_debe       LIKE bsid-dmbtr,
        v_haber      LIKE bsid-dmbtr,
        v_dif        LIKE bsid-dmbtr.

  IF s_monat-high IS INITIAL.
    s_monat-high = s_monat-low.
  ENDIF.

  companycode  = p_bukrs.
  fiscalyear   = p_gjahr.
  currencytype = '10'.

  LOOP AT i_cliente.
    CLEAR i_items. REFRESH i_items.
    glacct    = i_cliente-saknr.


    CALL FUNCTION 'BAPI_GL_GETGLACCPERIODBALANCES'
      EXPORTING
        companycode                   = companycode
        glacct                        = glacct
        fiscalyear                    = fiscalyear
        currencytype                  = currencytype
*     IMPORTING
*       BALANCE_CARRIED_FORWARD       =
*       RETURN                        =

      TABLES
        account_balances              = i_items.


    CLEAR: v_debe, v_haber.
    LOOP AT i_items WHERE fis_period IN s_monat.

      i_items-credit_per = i_items-credit_per * ( - 1 ).
      v_haber = v_haber + i_items-credit_per.
      v_debe  = v_debe  + i_items-debits_per.
    ENDLOOP.



    PERFORM name1_cliente USING i_cliente-saknr.
    PERFORM saldo USING i_datos-saldo.

    IF glacct = '0129000000'.
      PERFORM grupo0129 USING saldo.
    ENDIF.
    IF saldo < 0.
      v_haber = v_haber + ( saldo * ( - 1 ) ).
    ELSE.
      v_debe = v_debe + saldo.
    ENDIF.
    CLEAR saldo.

    IF glacct(2) NE '06' AND
      glacct(2) NE '07'.
      IF i_datos-saldo < 0.
        v_haber = v_haber + ( i_datos-saldo * ( - 1 ) ).
      ELSE.
        v_debe = v_debe + i_datos-saldo.
      ENDIF.
    ENDIF.

    MOVE: v_debe             TO i_datos-debe,
          v_haber            TO i_datos-haber,
          i_cliente-saknr    TO i_datos-saknr,
          skat-txt20         TO i_datos-name1.

    CONCATENATE 'Clase' i_cliente-saknr+1(1)
           INTO i_datos-clase SEPARATED BY space.

    v_dif = v_debe - v_haber.
    IF v_dif < 0.
      i_datos-dif_haber = v_dif * ( - 1 ).
    ELSE.
      i_datos-dif_debe  = v_dif.
    ENDIF.

    IF i_datos-debe      IS INITIAL AND
       i_datos-haber     IS INITIAL AND
       i_datos-saldo     IS INITIAL.
    ELSE.
      APPEND i_datos.
      CLEAR  i_datos.
    ENDIF.

  ENDLOOP.

ENDFORM.                    " procesa_datos

*&---------------------------------------------------------------------*
*&      Form  name1_cliente
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_CLIENTE_SAKNR  text
*----------------------------------------------------------------------*

FORM name1_cliente  USING    p_saknr.

  SELECT SINGLE * FROM skat WHERE spras = 'FR'
                              AND ktopl = 'SOCU'
                              AND saknr = p_saknr.

ENDFORM.                    " name1_cliente

*&---------------------------------------------------------------------*
*&      Form  saldo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_DATOS_saldo  text
*----------------------------------------------------------------------*

FORM saldo  USING    p_saldo.
  DATA: BEGIN OF balance OCCURS 0.
          INCLUDE STRUCTURE bapi1028_3.
  DATA: END   OF balance.

  DATA: companycode   LIKE bapi1028_0-comp_code,
        glacct        LIKE bapi1028_0-gl_account,
        fiscalyear    LIKE bapi1028_3-fisc_year,
        currencytype  LIKE bapi1028_5-curr_type.

  companycode  = p_bukrs.
  glacct       = i_cliente-saknr.
  fiscalyear   = p_gjahr - 1.
  currencytype = '10'.

*-- bapi para sacar el saldo anterior.
  CALL FUNCTION 'BAPI_GL_GETGLACCBALANCE'
    EXPORTING
      companycode     = companycode
      glacct          = glacct
      fiscalyear      = fiscalyear
      currencytype    = currencytype
    IMPORTING
      account_balance = balance.
*     RETURN                = .

  p_saldo = balance-balance.

ENDFORM.                    " saldo

*&---------------------------------------------------------------------*
*&      Form  pinta
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM pinta .
  DATA: var_saldo(30),
        var_debe(30),
        var_haber(30),
        anio(4).

  repname = sy-repid.
  anio    = p_gjahr - 1.

* Descripción estándar de campos
  IF NOT cta_alt IS INITIAL.
    PERFORM obt_descrip_campos_tabla USING repname 'I_DATOS2'.
  ELSE.
    PERFORM obt_descrip_campos_tabla USING repname 'I_DATOS'.
  ENDIF.
* Asignar TOP OF PAGE
  PERFORM asignar_top_of_page.
* Quitamos el cero de los importes.
  PERFORM no_zero USING: 'DEBE'         'X',
                         'HABER'        'X',
                         'DIF_DEBE'     'X',
                         'DIF_HABER'    'X',
                         'SALDO'        'X'.
* Marcamos los campos de los sumatorios.
  PERFORM do_sum USING:  'DEBE'         'X',
                         'HABER'        'X',
                         'DIF_DEBE'     'X',
                         'DIF_HABER'    'X',
                         'SALDO'        'X'.

* Cambiamos la descripción
  CONCATENATE 'Débiteur' p_gjahr
         INTO var_debe SEPARATED BY space.

  CONCATENATE 'Créditeur' p_gjahr
         INTO var_haber SEPARATED BY space.

  CONCATENATE 'Solde' anio
         INTO var_saldo SEPARATED BY space.

  IF NOT cta_alt IS INITIAL.
    PERFORM cambio_descripcion USING:
     'CLASE2'                 'Clase'    'Clase'
                              'Clase'    'Clase',
     'DEBE'                  'Cumul Débit'    'Cumul Débit'
                             'Cumul Débit'    'Cumul Débit',
     'HABER'                 'Cumul Crédit'   'Cumul Crédit'
                             'Cumul Crédit'   'Cumul Crédit',
     'ALTKT'                 'Nº Compte'      'Nº Compte'
                             'Nº Compte'      'Nº Compte',
     'NAME1'                 'Intitulé'       'Intitulé'
                             'Intitulé'       'Intitulé',
     'DIF_DEBE'              var_debe         var_debe
                             var_debe         var_debe,
     'DIF_HABER'             var_haber        var_haber
                             var_haber        var_haber,
     'SALDO'                 var_saldo        var_saldo
                             var_saldo        var_saldo.
  ELSE.
    PERFORM cambio_descripcion USING:
     'CLASE'                 'Clase'    'Clase'
                             'Clase'    'Clase',
     'DEBE'                  'Cumul Débit'    'Cumul Débit'
                             'Cumul Débit'    'Cumul Débit',
     'HABER'                 'Cumul Crédit'   'Cumul Crédit'
                             'Cumul Crédit'   'Cumul Crédit',
     'SAKNR'                 'Nº Compte'      'Nº Compte'
                             'Nº Compte'      'Nº Compte',
     'NAME1'                 'Intitulé'       'Intitulé'
                             'Intitulé'       'Intitulé',
     'DIF_DEBE'              var_debe         var_debe
                             var_debe         var_debe,
     'DIF_HABER'             var_haber        var_haber
                             var_haber        var_haber,
     'SALDO'                 var_saldo        var_saldo
                             var_saldo        var_saldo.
  ENDIF.

* Características generales del listado
  PERFORM carac_gen_listado.
  PERFORM subtotal.

* Disposición
  gs_disvariant-report  = repname.

* Se muestra el listado
  IF NOT cta_alt IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program       = repname
        i_callback_pf_status_set = formname_pf_status_set
        i_callback_user_command  = formname_user_command
        is_layout                = layout
        it_fieldcat              = fieldtab[]
        it_events                = events[]
        i_save                   = 'A'
        it_sort                  = alv_sort[]
        is_variant               = gs_disvariant
      TABLES
        t_outtab                 = i_datos2
      EXCEPTIONS
        program_error            = 1
        OTHERS                   = 2.
  ELSE.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = repname
      i_callback_pf_status_set = formname_pf_status_set
      i_callback_user_command  = formname_user_command
      is_layout                = layout
      it_fieldcat              = fieldtab[]
      it_events                = events[]
      i_save                   = 'A'
      it_sort                  = alv_sort[]
      is_variant               = gs_disvariant
    TABLES
      t_outtab                 = i_datos
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
  ENDIF.


ENDFORM.                    " pinta


*&---------------------------------------------------------------------*
*&      Form  subtotal
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM subtotal.

  IF NOT cta_alt IS INITIAL.
    REFRESH alv_sort.
    CLEAR alv_sort.
    alv_sort-fieldname = 'CLASE2'.
    alv_sort-subtot = 'X'.
    APPEND alv_sort.

    REFRESH alv_sort2.
    CLEAR alv_sort.
    alv_sort2-fieldname = 'CLASE2'.
    alv_sort2-subtot = 'X'.
    alv_sort2-expa   = 'X'.
    alv_sort2-comp   = ' '.
    APPEND alv_sort2.
  ELSE.
    REFRESH alv_sort.
    CLEAR alv_sort.
    alv_sort-fieldname = 'CLASE'.
    alv_sort-subtot = 'X'.
    APPEND alv_sort.

    REFRESH alv_sort2.
    CLEAR alv_sort.
    alv_sort2-fieldname = 'CLASE'.
    alv_sort2-subtot = 'X'.
    alv_sort2-expa   = 'X'.
    alv_sort2-comp   = ' '.
    APPEND alv_sort2.
  ENDIF.

ENDFORM. " subtotal


*&---------------------------------------------------------------------*
*&      Form  cambio_descripcion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM cambio_descripcion USING pf_fieldname
                              pf_scrtext_l
                              pf_scrtext_m
                              pf_scrtext_s
                              pf_coltext.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-seltext_l = pf_scrtext_l.
    <fs>-seltext_m = pf_scrtext_m.
    <fs>-seltext_s = pf_scrtext_s.
    <fs>-reptext_ddic = pf_coltext.
  ENDIF.

ENDFORM.                    " cambio_descripcion

*&---------------------------------------------------------------------*
*&      Form  no_zero
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM no_zero USING pf_fieldname
                   p_zero.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-no_zero = p_zero.
  ENDIF.

ENDFORM.                    " no_zero

*&---------------------------------------------------------------------*
*&      Form  do_sum
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM do_sum USING pf_fieldname
                  p_sum.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-do_sum  = p_sum.
  ENDIF.

ENDFORM.                    " do_sum

*---------------------------------------------------------------------*
*       FORM alv_top_of_page                                          *
*---------------------------------------------------------------------*
*     Textos de cabecera
*       - typ,   " H = Header, S = Selection, A = Action
*       - key,
*       - info,
*---------------------------------------------------------------------*

FORM alv_top_of_page.

  DATA: lt_list_commentary TYPE slis_t_listheader,
        ls_list_commentary TYPE slis_listheader.
  DATA: v_date(60).

  SELECT SINGLE * FROM t001 WHERE bukrs = p_bukrs.

  CONCATENATE 'Du' '01/'
                   s_monat-low '/'
                   p_gjahr   'au'
                   '31/'
                   s_monat-high '/'
                   p_gjahr
         INTO v_date SEPARATED BY space.

* Componemos texto de cabecera
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'H'.
  ls_list_commentary-info = 'Balance des comptes généraux'.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'S'.
  ls_list_commentary-key  = 'Société:'.
  ls_list_commentary-info = t001-butxt.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'S'.
  ls_list_commentary-key  = 'Date comptable:'.
  ls_list_commentary-info = v_date.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'A'.
  ls_list_commentary-info = 'Edition Provisiore - Experimé en euros'.
  APPEND ls_list_commentary TO lt_list_commentary.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = lt_list_commentary.

ENDFORM.                    "alv_top_of_page

*&---------------------------------------------------------------------
*&    Form PF_STATUS
*&---------------------------------------------------------------------

FORM pf_status USING lt_cua_exclude TYPE slis_t_extab.
  SET PF-STATUS 'STATUS_100'.
ENDFORM.                    "pf_status

*&---------------------------------------------------------------------
*&    Form USER_COMMAND
*&---------------------------------------------------------------------

FORM user_command USING r_ucomm LIKE sy-ucomm
                        ls_selfield TYPE slis_selfield.

  CASE r_ucomm.
    WHEN '/&F03'.
      LEAVE TO TRANSACTION 'ZFIBAL029'.
*-- Gener
    WHEN 'GENER'.
      PERFORM alv_gener.
*-- Bilan
    WHEN 'BILAN'.
      PERFORM alv_bilan.

*-- Gestion
    WHEN 'GESTION'.
      PERFORM alv_gestion.
  ENDCASE.

ENDFORM.                    "user_command

*&---------------------------------------------------------------------*
*&      Form  alv_gener
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM alv_gener .

* Se muestra el listado general
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = repname
      i_callback_pf_status_set = formname_pf_status_set
      i_callback_user_command  = formname_user_command
      is_layout                = layout
      it_fieldcat              = fieldtab[]
      it_events                = events[]
      i_save                   = 'A'
      it_sort                  = alv_sort[]
      is_variant               = gs_disvariant
    TABLES
      t_outtab                 = i_datos
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

ENDFORM.                    " alv_gener

*&---------------------------------------------------------------------*
*&      Form  alv_bilan
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM alv_bilan .
  CLEAR i_datos_bilan. REFRESH i_datos_bilan.

  LOOP AT i_datos WHERE clase+6(1) <= 5.
    MOVE-CORRESPONDING i_datos TO i_datos_bilan.
    APPEND i_datos_bilan.
    CLEAR  i_datos_bilan.
  ENDLOOP.

* Se muestra el listado bilan
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = repname
      i_callback_pf_status_set = formname_pf_status_set
      i_callback_user_command  = formname_user_command
      is_layout                = layout
      it_fieldcat              = fieldtab[]
      it_events                = events[]
      i_save                   = 'A'
      it_sort                  = alv_sort2[]
      is_variant               = gs_disvariant
    TABLES
      t_outtab                 = i_datos_bilan
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

ENDFORM.                    " alv_bilan

*&---------------------------------------------------------------------*
*&      Form  alv_gestion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM alv_gestion .
  CLEAR i_datos_gestion. REFRESH i_datos_gestion.

  LOOP AT i_datos WHERE ( clase+6(1) = 6 OR
                          clase+6(1) = 7 ).
    MOVE-CORRESPONDING i_datos TO i_datos_gestion.
    APPEND i_datos_gestion.
    CLEAR  i_datos_gestion.
  ENDLOOP.

* Se muestra el listado gestion
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = repname
      i_callback_pf_status_set = formname_pf_status_set
      i_callback_user_command  = formname_user_command
      is_layout                = layout
      it_fieldcat              = fieldtab[]
      it_events                = events[]
      i_save                   = 'A'
      it_sort                  = alv_sort2[]
      is_variant               = gs_disvariant
    TABLES
      t_outtab                 = i_datos_gestion
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.

ENDFORM.                    " alv_gestion
*&---------------------------------------------------------------------*
*&      Form  grupo0129
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_SALDO  text
*----------------------------------------------------------------------*

FORM grupo0129  USING    P_R_SALDO.

  DATA: BEGIN OF balan1 OCCURS 0.
          INCLUDE STRUCTURE bapi1028_3.
  DATA: END   OF balan1.

  DATA: companycod1   LIKE bapi1028_0-comp_code,
        glacc1       LIKE bapi1028_0-gl_account,
        fiscalyea1    LIKE bapi1028_3-fisc_year,
        currencytyp1  LIKE bapi1028_5-curr_type.


  SELECT * FROM ska1 WHERE ktopl = 'SOCU'
                           AND     saknr BETWEEN '0600000000'
                           AND     '0799999999'.

    companycod1  = p_bukrs.
    glacc1       = ska1-saknr.
    fiscalyea1   = p_gjahr - 1.
    currencytyp1 = '10'.

*-- bapi para sacar el saldo anterior.
    CALL FUNCTION 'BAPI_GL_GETGLACCBALANCE'
      EXPORTING
        companycode     = companycod1
        glacct          = glacc1
        fiscalyear      = fiscalyea1
        currencytype    = currencytyp1
      IMPORTING
        account_balance = balan1.
*     RETURN                = .

      p_r_saldo = p_r_saldo + balan1-balance.
  ENDSELECT.

ENDFORM.                    " grupo0129
*&---------------------------------------------------------------------*
*&      Form  ctaltern
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM ctaltern .

  LOOP AT i_datos.
    CALL FUNCTION 'READ_SKB1'
        EXPORTING
          xbukrs = p_bukrs
          xsaknr = i_datos-saknr
        IMPORTING
          xskb1  = skb1.

*    SELECT SINGLE * FROM t001
*                    WHERE bukrs = p_bukrs.

*    SELECT SINGLE * FROM skat
*                    WHERE ktopl = t001-ktop2
*                    AND saknr   = skb1-altkt.
*    IF skat-txt50 IS INITIAL.
*      MOVE text-601 TO skat-txt50.
*    ENDIF.
*    one_gsb = ' '.
*    MOVE skb1-altkt TO konto.

    MOVE-CORRESPONDING i_datos TO i_datos2.
    CONCATENATE 'Clase' skb1-altkt+1(1)
           INTO i_datos2-clase2 SEPARATED BY space.
    MOVE skb1-altkt TO i_datos2-altkt.
    COLLECT i_datos2.
    clear skb1.
  ENDLOOP.

  SORT i_datos2 BY altkt.
  DELETE ADJACENT DUPLICATES FROM i_datos2.


  SELECT SINGLE * FROM t001
                  WHERE bukrs = p_bukrs.
  LOOP AT i_datos2.
    PERFORM name2_cliente USING i_datos2-altkt t001-ktop2.
  ENDLOOP.

ENDFORM.                    " ctaltern
*&---------------------------------------------------------------------*
*&      Form  name2_cliente
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_DATOS2_ALTKT  text
*----------------------------------------------------------------------*

FORM name2_cliente  USING    P_I_DATOS2_ALTKT p_i_t001_ktop2.

  SELECT SINGLE * FROM skat WHERE spras = 'FR'
                              AND ktopl = p_i_t001_ktop2
                              AND saknr = p_i_datos2_altkt.

  i_datos2-name2 = skat-txt20.
  MODIFY i_datos2.
  CLEAR skat.

ENDFORM.                    " name2_cliente

23
Informes / Informe en ALV para ver los Balances de los Proveedores.
« en: 27 de Agosto de 2007, 06:20:02 pm »
En este informe podemos ver los Balances de los Proveedores, para ello utilizamos la BAPI BAPI_AP_ACC_GETSTATEMENT.

El Include ZALV lo podemos copiar de este mismo foro en el apartado de los Includes.




REPORT  zfi_bal_fournisseurs.

************************************************************************
*  DEFINICION TABLAS, ESTRUCTURAS Y TIPOS                              *
************************************************************************

*--DEFINICION DE TABLAS DE SISTEMA

TABLES: bsad,       "Contabilidad: índice secundario para deudores
        glt0,       "Cifras movimientos reg.maestro ctas.mayor
        lfa1,
        t001.




*--DEFINICION DE TABLAS INTERNAS
*-- tabla de clientes

DATA: BEGIN OF i_cliente OCCURS 0,
    lifnr LIKE lfa1-lifnr.
DATA: END OF i_cliente.

*-- tabla para ALV
DATA: BEGIN OF i_datos OCCURS 0,
    debe      LIKE bsid-dmbtr,
    haber     LIKE bsid-dmbtr,
    lifnr     LIKE lfa1-lifnr,
    name1     LIKE lfa1-name1,
    dif_debe  LIKE bsid-dmbtr,
    dif_haber LIKE bsid-dmbtr,
    saldo     LIKE bsid-dmbtr,
      END OF i_datos.

DATA: gs_disvariant TYPE disvariant.

INCLUDE zalv.

************************************************************************
*  DEFINICION DE PARAMETROS DE SELECCION                               *
************************************************************************


SELECTION-SCREEN BEGIN OF BLOCK uno WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_bukrs LIKE glt0-bukrs OBLIGATORY.       "Sociedad
SELECT-OPTIONS: s_lifnr FOR bsad-kunnr,               "Nº cuenta
                s_budat FOR bsad-budat OBLIGATORY.    "Fecha contab.

SELECTION-SCREEN END OF BLOCK uno.





************************************************************************
*  DEFINICION DE VARIABLES                                             *
************************************************************************






************************************************************************
*                                                                      *
*                                                                      *
*                        T R A T A M I E N T O                         *
*                                                                      *
*                                                                      *
************************************************************************

*----------------------------------------------------------------------*
*     START-OF-SELECTION                                               *
*----------------------------------------------------------------------*


START-OF-SELECTION.
  PERFORM selecciona_datos.
  PERFORM procesa_datos.

END-OF-SELECTION.
  PERFORM pinta.




************************************************************************
*                                                                      *
*                                                                      *
*                        S U B - R U T I N A S                         *
*                                                                      *
*                                                                      *
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  selecciona_datos
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM selecciona_datos .

  SELECT * APPENDING CORRESPONDING FIELDS OF TABLE i_cliente
                FROM lfa1
               WHERE lifnr IN s_lifnr.

ENDFORM.                    " selecciona_datos

*&---------------------------------------------------------------------*
*&      Form  procesa_datos
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM procesa_datos .

  DATA: BEGIN OF i_items OCCURS 0.
          INCLUDE STRUCTURE bapi3008_2.
  DATA: END   OF i_items.

  DATA: companycode LIKE  bapi3008_1-comp_code,
        vendor      LIKE  bapi3008_1-vendor,
        date_from   LIKE  bapi3008-from_date,
        date_to     LIKE  bapi3008-to_date,
        v_debe      LIKE bsid-dmbtr,
        v_haber     LIKE bsid-dmbtr,
        v_dif       LIKE bsid-dmbtr.

  IF s_budat-high IS INITIAL.
    s_budat-high = s_budat-low.
  ENDIF.

  companycode = p_bukrs.
  date_from   = s_budat-low.
  date_to     = s_budat-high.


  LOOP AT i_cliente.
    CLEAR i_items. REFRESH i_items.
    vendor    = i_cliente-lifnr.



    CALL FUNCTION 'BAPI_AP_ACC_GETSTATEMENT'
      EXPORTING
        companycode       = p_bukrs
        vendor            = vendor
        date_from         = date_from
        date_to           = date_to
*     NOTEDITEMS        = ' '
*     IMPORTING
*      RETURN            =

      TABLES
        lineitems         = i_items.


    CLEAR: v_debe, v_haber.
    LOOP AT i_items.

      IF i_items-db_cr_ind = 'S'.
        v_debe  = v_debe + i_items-amount.
      ELSE.
        v_haber = v_haber + i_items-amount.
      ENDIF.

    ENDLOOP.

    PERFORM name1_cliente USING i_cliente-lifnr.
    PERFORM saldo USING i_datos-saldo.
    if i_datos-saldo < 0.
      v_haber = v_haber + ( i_datos-saldo * ( - 1 ) ).
    else.
      v_debe = v_debe + i_datos-saldo.
    endif.

    MOVE: v_debe          TO i_datos-debe,
          v_haber         TO i_datos-haber,
          i_cliente-lifnr TO i_datos-lifnr,
          lfa1-name1      TO i_datos-name1.

    v_dif = v_debe - v_haber.
    IF v_dif < 0.
      i_datos-dif_haber = v_dif * ( - 1 ).
    ELSE.
      i_datos-dif_debe  = v_dif.
    ENDIF.

*   PERFORM saldo USING i_datos-saldo.
    IF i_datos-debe      IS INITIAL AND
       i_datos-haber     IS INITIAL AND
       i_datos-saldo     IS INITIAL.
    ELSE.
      APPEND i_datos.
      CLEAR  i_datos.
    ENDIF.

  ENDLOOP.

ENDFORM.                    " procesa_datos

*&---------------------------------------------------------------------*
*&      Form  name1_cliente
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LIFNR  text
*----------------------------------------------------------------------*

FORM name1_cliente  USING    p_lifnr.

  SELECT SINGLE * FROM lfa1 WHERE lifnr = p_lifnr.

ENDFORM.                    " name1_cliente

*&---------------------------------------------------------------------*
*&      Form  saldo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_DATOS_saldo  text
*----------------------------------------------------------------------*

FORM saldo  USING    p_saldo.
  DATA: BEGIN OF keybalance OCCURS 0.
          INCLUDE STRUCTURE bapi3008_3.
  DATA: END   OF keybalance.

  DATA: companycode LIKE bapi3008_1-comp_code,
        vendor      LIKE bapi3008_1-vendor,
        keydate     LIKE bapi3008-key_date,
        anio(4).

  companycode = p_bukrs.
  vendor      = i_cliente-lifnr.
  anio        = s_budat-high(4) - 1.

  CONCATENATE anio '1231' INTO keydate.

*-- BAPI para sacar el Saldo Anterior.
  CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
    EXPORTING
      companycode = companycode
      vendor      = vendor
      keydate     = keydate
    TABLES
      keybalance  = keybalance.

  p_saldo = keybalance-lc_bal.

ENDFORM.                    " saldo

*&---------------------------------------------------------------------*
*&      Form  pinta
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM pinta .
  DATA: var_saldo(30),
        var_debe(30),
        var_haber(30),
        anio(4).

  repname = sy-repid.
  anio    = s_budat-high(4) - 1.

* Descripción estándar de campos
  PERFORM obt_descrip_campos_tabla USING repname 'I_DATOS'.
* Asignar TOP OF PAGE
  PERFORM asignar_top_of_page.
* Quitamos el cero de los importes.
  PERFORM no_zero USING: 'DEBE'         'X',
                         'HABER'        'X',
                         'DIF_DEBE'     'X',
                         'DIF_HABER'    'X',
                         'SALDO'        'X'.
* Marcamos los campos de los sumatorios.
  PERFORM no_sum USING: 'DEBE'         'X',
                        'HABER'        'X',
                        'DIF_DEBE'     'X',
                        'DIF_HABER'    'X',
                        'SALDO'        'X'.
* Cambiamos la descripción
  CONCATENATE 'Débiteur' s_budat-high(4)
         INTO var_debe SEPARATED BY space.

  CONCATENATE 'Créditeur' s_budat-high(4)
         INTO var_haber SEPARATED BY space.

  CONCATENATE 'Solde' anio
         INTO var_saldo SEPARATED BY space.

  PERFORM cambio_descripcion USING:
   'DEBE'                  'Cumul Débit'    'Cumul Débit'
                           'Cumul Débit'    'Cumul Débit',
   'HABER'                 'Cumul Crédit'   'Cumul Crédit'
                           'Cumul Crédit'   'Cumul Crédit',
   'LIFNR'                 'Nº Compte'      'Nº Compte'
                           'Nº Compte'      'Nº Compte',
   'NAME1'                 'Intitulé'       'Intitulé'
                           'Intitulé'       'Intitulé',
   'DIF_DEBE'              var_debe         var_debe
                           var_debe         var_debe,
   'DIF_HABER'             var_haber        var_haber
                           var_haber        var_haber,
   'SALDO'                 var_saldo        var_saldo
                           var_saldo        var_saldo.

* Características generales del listado
  PERFORM carac_gen_listado.

* Disposición
  gs_disvariant-report  = repname.

* Se muestra el listado
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = repname
      is_layout          = layout
      it_fieldcat        = fieldtab[]
      it_events          = events[]
      i_save             = 'A'
      is_variant         = gs_disvariant
    TABLES
      t_outtab           = i_datos
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.

ENDFORM.                    " pinta

*&---------------------------------------------------------------------*
*&      Form  cambio_descripcion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM cambio_descripcion USING pf_fieldname
                              pf_scrtext_l
                              pf_scrtext_m
                              pf_scrtext_s
                              pf_coltext.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-seltext_l = pf_scrtext_l.
    <fs>-seltext_m = pf_scrtext_m.
    <fs>-seltext_s = pf_scrtext_s.
    <fs>-reptext_ddic = pf_coltext.
  ENDIF.

ENDFORM.                    " cambio_descripcion

*&---------------------------------------------------------------------*
*&      Form  no_zero
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM no_zero USING pf_fieldname
                   p_zero.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-no_zero = p_zero.
  ENDIF.

ENDFORM.                    " no_zero

*&---------------------------------------------------------------------*
*&      Form  no_sum
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM no_sum USING pf_fieldname
                  p_sum.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-do_sum  = p_sum.
  ENDIF.

ENDFORM.                    " p_sum

*---------------------------------------------------------------------*
*       FORM alv_top_of_page                                          *
*---------------------------------------------------------------------*
*     Textos de cabecera
*       - typ,   " H = Header, S = Selection, A = Action
*       - key,
*       - info,
*---------------------------------------------------------------------*

FORM alv_top_of_page.

  DATA: lt_list_commentary TYPE slis_t_listheader,
        ls_list_commentary TYPE slis_listheader.
  DATA: v_date(60).

  SELECT SINGLE * FROM t001 WHERE bukrs = p_bukrs.

  CONCATENATE 'Du' s_budat-low+6(2) '/'
                   s_budat-low+4(2) '/'
                   s_budat-low(4)   'au'
                   s_budat-high+6(2) '/'
                   s_budat-high+4(2) '/'
                   s_budat-high(4)
         INTO v_date SEPARATED BY space.

* Componemos texto de cabecera
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'H'.
  ls_list_commentary-info = 'Balance des comptes fournisseurs'.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'S'.
  ls_list_commentary-key  = 'Société:'.
  ls_list_commentary-info = t001-butxt.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'S'.
  ls_list_commentary-key  = 'Date comptable:'.
  ls_list_commentary-info = v_date.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'A'.
  ls_list_commentary-info = 'Edition Provisiore - Experimé en euros'.
  APPEND ls_list_commentary TO lt_list_commentary.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = lt_list_commentary.

ENDFORM.                    "alv_top_of_page

24
Informes / Informe en ALV para ver los Balances de los Clientes.
« en: 27 de Agosto de 2007, 06:06:14 pm »
En este informe podemos ver los Balances de los Clientes.

El Include ZALV lo podemos copiar de este mismo foro en el apartado de los Includes.



REPORT  zfi_bal_client.


************************************************************************
*  DEFINICION TABLAS, ESTRUCTURAS Y TIPOS                              *
************************************************************************

*--DEFINICION DE TABLAS DE SISTEMA

TABLES: bsad,       "Contabilidad: índice secundario para deudores
        glt0,       "Cifras movimientos reg.maestro ctas.mayor
        kna1,
        t001.




*--DEFINICION DE TABLAS INTERNAS
*-- tabla de clientes

DATA: BEGIN OF i_cliente OCCURS 0,
    kunnr LIKE kna1-kunnr.
DATA: END OF i_cliente.

*-- tabla para ALV
DATA: BEGIN OF i_datos OCCURS 0,
    debe      LIKE bsid-dmbtr,
    haber     LIKE bsid-dmbtr,
    kunnr     LIKE kna1-kunnr,
    name1     LIKE kna1-name1,
    dif_debe  LIKE bsid-dmbtr,
    dif_haber LIKE bsid-dmbtr,
    saldo     LIKE bsid-dmbtr,
      END OF i_datos.

DATA: gs_disvariant TYPE disvariant.

INCLUDE zalv.


************************************************************************
*  DEFINICION DE PARAMETROS DE SELECCION                               *
************************************************************************


SELECTION-SCREEN BEGIN OF BLOCK uno WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_bukrs LIKE glt0-bukrs OBLIGATORY.       "Sociedad
SELECT-OPTIONS: s_kunnr FOR bsad-kunnr,               "Nº cuenta
                s_budat FOR bsad-budat OBLIGATORY.    "Fecha contab.

SELECTION-SCREEN END OF BLOCK uno.






************************************************************************
*  DEFINICION DE VARIABLES                                             *
************************************************************************






************************************************************************
*                                                                      *
*                                                                      *
*                        T R A T A M I E N T O                         *
*                                                                      *
*                                                                      *
************************************************************************

*----------------------------------------------------------------------*
*     START-OF-SELECTION                                               *
*----------------------------------------------------------------------*

START-OF-SELECTION.
  PERFORM selecciona_datos.
  PERFORM procesa_datos.

END-OF-SELECTION.
  PERFORM pinta.





************************************************************************
*                                                                      *
*                                                                      *
*                        S U B - R U T I N A S                         *
*                                                                      *
*                                                                      *
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  selecciona_datos
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM selecciona_datos .

  SELECT * APPENDING CORRESPONDING FIELDS OF TABLE i_cliente
                FROM kna1
               WHERE kunnr IN s_kunnr.

ENDFORM.                    " selecciona_datos


*&---------------------------------------------------------------------*
*&      Form  procesa_datos
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM procesa_datos .
  DATA: BEGIN OF i_items OCCURS 0.
          INCLUDE STRUCTURE bapi3007_2.
  DATA: END   OF i_items.

  DATA: companycode LIKE  bapi3007_1-comp_code,
        customer    LIKE  bapi3007_1-customer,
        date_from   LIKE  bapi3007-from_date,
        date_to     LIKE  bapi3007-to_date,
        v_debe      LIKE bsid-dmbtr,
        v_haber     LIKE bsid-dmbtr,
        v_dif       LIKE bsid-dmbtr.

  IF s_budat-high IS INITIAL.
    s_budat-high = s_budat-low.
  ENDIF.

  companycode = p_bukrs.
  date_from   = s_budat-low.
  date_to     = s_budat-high.


  LOOP AT i_cliente.
    CLEAR i_items. REFRESH i_items.
    customer    = i_cliente-kunnr.



    CALL FUNCTION 'BAPI_AR_ACC_GETSTATEMENT'
      EXPORTING
        companycode       = p_bukrs
        customer          = customer
        date_from         = date_from
        date_to           = date_to
*     NOTEDITEMS        = ' '
*     IMPORTING
*      RETURN            =

      TABLES
        lineitems         = i_items.


    CLEAR: v_debe, v_haber.
    LOOP AT i_items.

      IF i_items-db_cr_ind = 'S'.
        v_debe  = v_debe + i_items-amount.
      ELSE.
        v_haber = v_haber + i_items-amount.
      ENDIF.

    ENDLOOP.

    PERFORM name1_cliente USING i_cliente-kunnr.
    PERFORM saldo USING i_datos-saldo.
    if i_datos-saldo < 0.
      v_haber = v_haber + ( i_datos-saldo * ( - 1 ) ).
    else.
      v_debe = v_debe + i_datos-saldo.
    endif.

    MOVE: v_debe          TO i_datos-debe,
          v_haber         TO i_datos-haber,
          i_cliente-kunnr TO i_datos-kunnr,
          kna1-name1      TO i_datos-name1.

    v_dif = v_debe - v_haber.
    IF v_dif < 0.
      i_datos-dif_haber = v_dif * ( - 1 ).
    ELSE.
      i_datos-dif_debe  = v_dif.
    ENDIF.


*    PERFORM saldo USING i_datos-saldo.

    IF i_datos-debe      IS INITIAL AND
       i_datos-haber     IS INITIAL AND
       i_datos-saldo     IS INITIAL.
    ELSE.
      APPEND i_datos.
      CLEAR  i_datos.
    ENDIF.

  ENDLOOP.

ENDFORM.                    " procesa_datos


*&---------------------------------------------------------------------*
*&      Form  name1_cliente
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_CLIENTE_KUNNR  text
*----------------------------------------------------------------------*

FORM name1_cliente  USING    p_kunnr.

  SELECT SINGLE * FROM kna1 WHERE kunnr = p_kunnr.

ENDFORM.                    " name1_cliente


*&---------------------------------------------------------------------*
*&      Form  saldo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_DATOS_saldo  text
*----------------------------------------------------------------------*

FORM saldo  USING    p_saldo.
  DATA: BEGIN OF keybalance OCCURS 0.
          INCLUDE STRUCTURE bapi3007_3.
  DATA: END   OF keybalance.

  DATA: companycode LIKE bapi3007_1-comp_code,
        customer    LIKE bapi3007_1-customer,
        keydate     LIKE bapi3007-key_date,
        anio(4).

  companycode = p_bukrs.
  customer    = i_cliente-kunnr.
  anio        = s_budat-high(4) - 1.

  CONCATENATE anio '1231' INTO keydate.


*-- BAPI para sacar el Saldo Anterior.

  CALL FUNCTION 'BAPI_AR_ACC_GETKEYDATEBALANCE'
    EXPORTING
      companycode = companycode
      customer    = customer
      keydate     = keydate
    TABLES
      keybalance  = keybalance.

  p_saldo = keybalance-lc_bal.

ENDFORM.                    " saldo


*&---------------------------------------------------------------------*
*&      Form  pinta
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM pinta .
  DATA: var_saldo(30),
        var_debe(30),
        var_haber(30),
        anio(4).

  repname = sy-repid.
  anio    = s_budat-high(4) - 1.

* Descripción estándar de campos
  PERFORM obt_descrip_campos_tabla USING repname 'I_DATOS'.
* Asignar TOP OF PAGE
  PERFORM asignar_top_of_page.
* Quitamos el cero de los importes.
  PERFORM no_zero USING: 'DEBE'         'X',
                         'HABER'        'X',
                         'DIF_DEBE'     'X',
                         'DIF_HABER'    'X',
                         'SALDO'        'X'.
* Marcamos los campos de los sumatorios.
  PERFORM no_sum USING: 'DEBE'         'X',
                        'HABER'        'X',
                        'DIF_DEBE'     'X',
                        'DIF_HABER'    'X',
                        'SALDO'        'X'.
* Cambiamos la descripción
  CONCATENATE 'Débiteur' s_budat-high(4)
         INTO var_debe SEPARATED BY space.

  CONCATENATE 'Créditeur' s_budat-high(4)
         INTO var_haber SEPARATED BY space.

  CONCATENATE 'Solde' anio
         INTO var_saldo SEPARATED BY space.

  PERFORM cambio_descripcion USING:
   'DEBE'                  'Cumul Débit'    'Cumul Débit'
                           'Cumul Débit'    'Cumul Débit',
   'HABER'                 'Cumul Crédit'   'Cumul Crédit'
                           'Cumul Crédit'   'Cumul Crédit',
   'KUNNR'                 'Nº Compte'      'Nº Compte'
                           'Nº Compte'      'Nº Compte',
   'NAME1'                 'Intitulé'       'Intitulé'
                           'Intitulé'       'Intitulé',
   'DIF_DEBE'              var_debe         var_debe
                           var_debe         var_debe,
   'DIF_HABER'             var_haber        var_haber
                           var_haber        var_haber,
   'SALDO'                 var_saldo        var_saldo
                           var_saldo        var_saldo.

* Características generales del listado
  PERFORM carac_gen_listado.

* Disposición  gs_disvariant-report  = repname.

* Se muestra el listado
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = repname
      is_layout          = layout
      it_fieldcat        = fieldtab[]
      it_events          = events[]
      i_save             = 'A'
      is_variant         = gs_disvariant
    TABLES
      t_outtab           = i_datos
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.

ENDFORM.                    " pinta

*&---------------------------------------------------------------------*
*&      Form  cambio_descripcion
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM cambio_descripcion USING pf_fieldname
                              pf_scrtext_l
                              pf_scrtext_m
                              pf_scrtext_s
                              pf_coltext.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-seltext_l = pf_scrtext_l.
    <fs>-seltext_m = pf_scrtext_m.
    <fs>-seltext_s = pf_scrtext_s.
    <fs>-reptext_ddic = pf_coltext.
  ENDIF.

ENDFORM.                    " cambio_descripcion

*&---------------------------------------------------------------------*
*&      Form  no_zero
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM no_zero USING pf_fieldname
                   p_zero.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-no_zero = p_zero.
  ENDIF.

ENDFORM.                    " no_zero

*&---------------------------------------------------------------------*
*&      Form  no_sum
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM no_sum USING pf_fieldname
                  p_sum.

  READ TABLE fieldtab WITH KEY fieldname = pf_fieldname ASSIGNING <fs>.
  IF sy-subrc EQ 0.
    <fs>-do_sum  = p_sum.
  ENDIF.

ENDFORM.                    " p_sum

*---------------------------------------------------------------------*
*       FORM alv_top_of_page                                          *
*---------------------------------------------------------------------*
*     Textos de cabecera
*       - typ,   " H = Header, S = Selection, A = Action
*       - key,
*       - info,
*---------------------------------------------------------------------*

FORM alv_top_of_page.

  DATA: lt_list_commentary TYPE slis_t_listheader,
        ls_list_commentary TYPE slis_listheader.
  DATA: v_date(60).

  SELECT SINGLE * FROM t001 WHERE bukrs = p_bukrs.

  CONCATENATE 'Du' s_budat-low+6(2) '/'
                   s_budat-low+4(2) '/'
                   s_budat-low(4)   'au'
                   s_budat-high+6(2) '/'
                   s_budat-high+4(2) '/'
                   s_budat-high(4)
         INTO v_date SEPARATED BY space.

* Componemos texto de cabecera
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'H'.
  ls_list_commentary-info = 'Balance des comptes clients'.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'S'.
  ls_list_commentary-key  = 'Société:'.
  ls_list_commentary-info = t001-butxt.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'S'.
  ls_list_commentary-key  = 'Date comptable:'.
  ls_list_commentary-info = v_date.
  APPEND ls_list_commentary TO lt_list_commentary.
*
  CLEAR ls_list_commentary.
  ls_list_commentary-typ  = 'A'.
  ls_list_commentary-info = 'Edition Provisiore - Experimé en euros'.
  APPEND ls_list_commentary TO lt_list_commentary.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = lt_list_commentary.

ENDFORM.                    "alv_top_of_page

25
Reports / Enviar mail a un correo externo
« en: 26 de Julio de 2007, 01:21:53 pm »
Con este código podremos enviar de forma sencilla un correo a una dirección e-mail externa.

Hay que tener configurado el SAPconect para que el envío se haga de forma inmediata.



  DATA: BEGIN OF i_text OCCURS 0.
          INCLUDE STRUCTURE soli.
  DATA: END OF i_text.

  DATA: wspoolnumber   LIKE  sy-spono ,
        wmailname      LIKE  sood1-objnam,
        wsubject       LIKE  sood1-objdes ,
        wrecepient(40) TYPE  c ,
        wdli           LIKE  soos1-dlinam.

  DATA: object_hd_change LIKE sood1 OCCURS 0 WITH HEADER LINE,
        objpara          LIKE selc  OCCURS 0 WITH HEADER LINE,
        receivers        LIKE soos1 OCCURS 0 WITH HEADER LINE.

  DATA: BEGIN OF i_receivers OCCURS 0.
          INCLUDE STRUCTURE receivers.
  DATA: END OF i_receivers.



  wsubject     = 'Entrega numero....1234567890.'.
  wrecepient   = 'tu_correo@algo.com'.



  object_hd_change-objla  = sy-langu.
  object_hd_change-objnam = wmailname.
  object_hd_change-objdes = wsubject.
  object_hd_change-objsns = 'F'.
  object_hd_change-vmtyp  = 'T'.
  object_hd_change-skips  = 'X'.
  object_hd_change-acnam  = 'SP01'.
  object_hd_change-objcp  = 'X'.



  REFRESH i_text.
  CLEAR i_text.
  i_text-line = 'Texto del mensaje'.
  APPEND i_text.



  REFRESH i_receivers.
  CLEAR i_receivers.
  i_receivers-rcdat  = sy-datum.
  i_receivers-rctim  = sy-uzeit.
  i_receivers-recextnam = wrecepient.
  i_receivers-recesc = 'U'.
  i_receivers-sndex  = 'X'.     " Express-Mail
  APPEND i_receivers.


  objpara-name = 'SPI'.
  objpara-low  = wspoolnumber.
  APPEND objpara.


  CALL FUNCTION 'SO_OBJECT_SEND'
       EXPORTING
            object_hd_change           = object_hd_change
            object_type                = 'RAW'
            owner                      = sy-uname
       TABLES
            objcont                    = i_text
            receivers                  = i_receivers
       EXCEPTIONS
       active_user_not_exist            = 1
       communication_failure            = 2
       component_not_available          = 3
       folder_not_exist                 = 4
       folder_no_authorization          = 5
       forwarder_not_exist              = 6
       note_not_exist                   = 7
       object_not_exist                 = 8
       object_not_sent                  = 9
       object_no_authorization          = 10
       object_type_not_exist            = 11
       operation_no_authorization       = 12
       owner_not_exist                  = 13
       parameter_error                  = 14
       substitute_not_active            = 15
       substitute_not_defined           = 16
       system_failure                   = 17
       too_much_receivers               = 18
       user_not_exist                   = 19
       originator_not_exist             = 20
       x_error                          = 21
       OTHERS                           = 22.

  IF sy-subrc <> 0.
    WRITE: /'Error al enviar el mail'.
    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  COMMIT WORK.




Fijaros en la línea donde pone: wrecepient   = 'tu_correo@algo.com'. Hay que cambiar la dirección y poner una vuestra.

Saludos...

26
Reports / Busca User-Exit por transacción
« en: 24 de Julio de 2007, 09:45:51 am »
Este es uno de los programas que creo que está mas extendido por la red, es un programa que busca las User-Exit por transacción.

Simplemente hay que copiar el código, ejecutarlo y poner la transacción de la cual quieres buscar sus User...


* Finding the user-exits of a SAP transaction code
*
* Enter the transaction code in which you are looking for the user-exit
* and it will list you the list of user-exits in the transaction code.
* Also a drill down is possible which will help you to branch to SMOD.
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
* http://www.sap-img.com


REPORT zodj_user_exit2 NO STANDARD PAGE HEADING.

TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
TABLES : tstct.
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.
PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.

SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
IF sy-subrc EQ 0.
  SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
  AND object = 'PROG'
  AND obj_name = tstc-pgmna.
  MOVE : tadir-devclass TO v_devclass.
  IF sy-subrc NE 0.
    SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
    IF trdir-subc EQ 'F'.
      SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna.
      SELECT SINGLE * FROM enlfdir WHERE funcname =
      tfdir-funcname.
      SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
      AND object = 'FUGR'
      AND obj_name EQ enlfdir-area.

      MOVE : tadir-devclass TO v_devclass.
    ENDIF.
  ENDIF.
  SELECT * FROM tadir INTO TABLE jtab
  WHERE pgmid = 'R3TR'
  AND object = 'SMOD'
  AND devclass = v_devclass.
  SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND
  tcode EQ p_tcode.
  FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
  WRITE:/(19) 'Transaction Code - ',
  20(20) p_tcode,
  45(50) tstct-ttext.
  SKIP.
  IF NOT jtab[] IS INITIAL.
    WRITE:/(95) sy-uline.
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE:/1 sy-vline,
    2 'Exit Name',
    21 sy-vline ,
    22 'Description',
    95 sy-vline.
    WRITE:/(95) sy-uline.
    LOOP AT jtab.
      SELECT SINGLE * FROM modsapt
      WHERE sprsl = sy-langu AND
      name = jtab-obj_name.
      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE:/1 sy-vline,
      2 jtab-obj_name HOTSPOT ON,
      21 sy-vline ,
      22 modsapt-modtext,
      95 sy-vline.
    ENDLOOP.
    WRITE:/(95) sy-uline.
    DESCRIBE TABLE jtab.
    SKIP.
    FORMAT COLOR COL_TOTAL INTENSIFIED ON.
    WRITE:/ 'No of Exits:' , sy-tfill.
  ELSE.
    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    WRITE:/(95) 'No User Exit exists'.
  ENDIF.
ELSE.
  FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
  WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.

AT LINE-SELECTION.
  GET CURSOR FIELD field1.
  CHECK field1(4) EQ 'JTAB'.
  SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
  CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
*---End of Program



27
Bapis / BAPI para sacar Saldos acumulados de Deudores y Acreedores
« en: 20 de Julio de 2007, 10:20:10 am »

La de Deudores sería:

    CALL FUNCTION 'BAPI_AR_ACC_GETKEYDATEBALANCE'
      EXPORTING
        companycode = companycode
        customer    = customer
        keydate     = keydate
      TABLES
        keybalance  = keybalance.


La de Acreedores:

    CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
      EXPORTING
        companycode = companycode
        vendor      = vendor
        keydate     = keydate
      TABLES
        keybalance  = keybalance.

28
Varios / MOVIDO: Imagen en SapScript
« en: 20 de Julio de 2007, 09:03:09 am »

29
Links / Mas Links
« en: 20 de Julio de 2007, 08:50:50 am »
Voy a aportar mi granito de arena... hace tiempo que vi este recolilatorio de enlaces, yo creo que nos va a entretener un rato verlos todos.

Por mi pate no los he visto todos todavía.
Si alguien se da cuenta sobre algún enlace que no funcione o que no sea sobre SAP que me lo diga para ir actualizandolo.

Un saludo...  :o

http://abap4.tripod.com/Other_Useful_Tips.html
http://cma.zdnet.com/book/abap/ch03/ch03.htm
http://cma.zdnet.com/book/abap/index.htm
http://help.sap.com
http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
http://juliet.stfx.ca/people/fac/infosys/abap.htm
http://members.aol.com/_ht_a/skarkada/sap/
http://members.ozemail.com.au/~anmari/sap/index.html
http://members.tripod.com/abap4/SAP_Functions.html
http://members.xoom.com/pmvsr
http://mini.net/cetus/oo_abap_objects.html
http://sap.ittoolbox.com/documents/document.asp?i=752
http://sapassist.com/
http://sapassist.com/groups/groups.asp?v=sap-r3-dev&m=3&y=2004
http://sapfans.com/
http://sappoint.com/abap/
http://training.saptechies.com/sap-basis-certification-sample-questions/
http://www.abap-cafe.com/
http://www.antarcon.de/
http://www.basisguru.com/
http://www.ct-software.com/reportpool_frame.htm
http://www.davatz.ch/
http://www.easymarketplace.de/online-pdfs-q-s.php
http://www.geocities.com/mpioud/Abap_programs.html
http://www.henrikfrank.dk/abapexamples/index.html
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
http://www.henrikfrank.dk/abapexamples/SapScript/symbols.htm
http://www.henrikfrank.dk/abapuk.html
http://www.intelligenterp.com/
http://www.kabai.com/abaps/q.htm
http://www.planetsap.com/howdo_a.htm
http://www.planetsap.com/Tips_and_Tricks.htm
http://www.planetsap.com/Userexit_List.htm
http://www.sapassist.com/code/d.asp?whichpage=1&pagesize=10&i=10&a=c&o=&t=&q=&qt=
http://www.sap-basis-abap.com/
http://www.sapdesignguild.org/resources/MiniSG/3_Managing/3_Functions_Table_Control.htm
http://www.sapdevelopment.co.uk/
http://www.sapfans.com/
http://www.sapgenie.com/abap/bapi/example.htm
http://www.sapgenie.com/abap/code/abap19.htm
http://www.sapgenie.com/abap/example_code.htm
http://www.sapgenie.com/abap/index.htm
http://www.sapgenie.com/abap/smartforms_detail.htm
http://www.sapgenie.com/abap/tips_and_tricks.htm
http://www.sap-img.com
http://www.sap-img.com/abap.htm
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.sap-img.com/abap-function.htm
http://www.sap-img.com/abap-function.htm
http://www.sappoint.com/
http://www.sapwired.com/ABAPCentral/
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
http://www.thespot4sap.com
http://www.wisgurd.de/index3.html
http://www50.sap.com/company/saplabs/northamerica/
https://websmp104.sap-ag.de/~SAPIDP/002006825000000234912001E

ABAP System Fields
http://help.sap.com/saphelp_46c/helpdata/en/7b/fb96c8882811d295a90000e8353423/content.htm

For FAQ
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.sapgenie.com/faq/abap.htm

BAPI-step by step
http://www.sapgenie.com/abap/bapi/example.htm

Weblog for receive email and processing it through ABAP
https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/795

For Logical database
http://help.sap.com/saphelp_46c/helpdata/en/9f/db9bed35c111d1829f0000e829fbfe/frameset.htm

very useful
http://help.sap.com/saphelp_46c/helpdata/EN/35/2cd77bd7705394e10000009b387c12/frameset.htm

Useful link to websites
http://www.hernangn.com.ar/sap.htm

Useful for background
http://www.sappoint.com/basis/bckprsng.pdf
http://help.sap.com/saphelp_nw04/helpdata/en/6f/08703713bf277ee10000009b38f8cf/frameset.htm

http://publib.boulder.ibm.com/infocenter/wbihelp/index.jsp?topic=/com.ibm.wbix_adapters.doc/doc/mysap4/sap4x41.htm

Table control in BDC
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

BDC
http://www.sap-img.com/bdc.htm

For posting weblog,
https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1936

Dynamic Internal table -weblog in sdn
https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1011

Smartforms
http://www.sap-basis-abap.com/sapsf001.htm
http://www.sap-press.com/downloads/h955_preview.pdf
http://www.ossincorp.com/Black_Box/Black_Box_2.htm
http://www.sap-img.com/smartforms/sap-smart-forms.htm

SapScript
http://www.sap-img.com/sapscripts.htm
http://sappoint.com/abap/
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm

How to trace smartform
http://help.sap.com/saphelp_47x200/helpdata/en/49/c3d8a4a05b11d5b6ef006094192fe3/frameset.htm

Mail
http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
http://www.sap-img.com/abap/sending-email-with-attachment.htm

BOM Explosion
https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1647

BOM
http://help.sap.com/saphelp_erp2005/helpdata/en/ea/e9b7234c7211d189520000e829fbbd/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/d1/2e4114a61711d2b423006094b9d648/frameset.htm
http://www.sap-img.com/sap-sd/sales-bom-implementation.htm
http://www.sap-basis-abap.com/sappp007.htm

OLE
http://www.sapgenie.com/abap/ole.htm
http://help.sap.com/saphelp_46c/helpdata/en/59/ae3f2e488f11d189490000e829fbbd/frameset.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf
http://help.sap.com/saphelp_47x200/helpdata/en/59/ae3cac488f11d189490000e829fbbd/content.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE6/BCFESDE6.pdf

ALVGRID with refresh
http://www.geocities.com/mpioud/Z_DEMO_ALV_REFRESH_BUTTON.html

ALV Group Heading
http://www.sap-img.com/fu037.htm
http://www.sap-img.com/abap/test-alv-display-with-header-footer.htm
http://www.sap-img.com/abap/sample-alv-heading-in-alv.htm

ALV all Imp
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sap-img.com/fu002.htm

http://www.sapdevelopment.co.uk/reporting/alvhome.htm
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_events.htm

ALV Documentation for Field
http://www.mpls.k12.mn.us/sites/f7071225-9844-4da6-96c0-996b9c74b221/uploads/SAP_Navigation_Training2.ppt

30
Programación ABAP / MOVIDO: Espero que sea de utilidad !
« en: 20 de Julio de 2007, 08:45:21 am »

Páginas: 1 [2] 3