Korrespondenzart anlegen

Anlegen einer Kunden eignen Korrespondenzart.

  1. Zeitpunkt zum Anlegen und Drucken definieren SM30 TFKFBM. Kopieren von z.B. R830 und R835
    Feld für Text eventuell über ALV-Layout dazu holen.
  2. SPRO > Anwendungsübergreifende Komponenten > Allgemeine Anwendungsfunktion > Korrespondenz > Korrenspondenzart definieren.
  3. Mit Transaktion FQB2 eventuell Felder hinterlegen die bei der Anlage eines Korrespondenzeintrags mit abgespeichert werden können. siehe FuBa FKK_FLD_2_CONTAINER
  4. SPRO > Anwendungsübergreifende Komponenten > Allgemeine Anwendungsfunktion > Korrespondenz > Standardformularklasse für Korresponden hinterlegen
  5. SPRO > Anwendungsübergreifende Komponenten > Allgemeine Anwendungsfunktion > Korrespondenz > Anwendungsformular für die Korrespondenz hinterlegen
  6. SPRO > Finanzwesen > VKK > Programmerweiterung >Zeitpunkte
  7. Zeitpunkt müssen erzeugt werden.
*FuBa zum Erzeugungszeitpunkt:
function zvm_cs_mi_eigent_sample_z835.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(X_LANGU) TYPE  SY-LANGU DEFAULT SY-LANGU
*"     REFERENCE(X_FORMKEY) TYPE  EPRINTPARAMS-FORMKEY DEFAULT
*"       'ZKV_CS_MI_EIGENT'
*"     REFERENCE(X_DELAYED_PRINT) TYPE  EPRINTPARAMS-DELAYED_PRINT
*"       DEFAULT 'X'
*"     REFERENCE(X_AUSWFORM) TYPE  EAUS-AUSWFORM
*"     REFERENCE(X_REPRINT) TYPE  REGEN-KENNZX
*"     REFERENCE(I_GPART) TYPE  GPART_KK
*"     REFERENCE(I_ANLAGE) TYPE  ANLAGE
*"     REFERENCE(I_FORM_TYP) TYPE  SWU_FRMTYP
*"     REFERENCE(I_PRIVAT) TYPE  ZE4U_HAUSHALTSKUNDE
*"     VALUE(I_VENDE) TYPE  E_VENDE
*"     REFERENCE(I_EVBEGINN) TYPE  DATS
*"     REFERENCE(I_EVENDE) TYPE  DATS
*"     VALUE(I_AN1_DAT) TYPE  VVEAANSCHD
*"     VALUE(I_AN2_DAT) TYPE  VVEAANSCHD
*"  EXPORTING
*"     VALUE(Y_FORMKEY) TYPE  EPRINTPARAMS-FORMKEY
*"  EXCEPTIONS
*"      ACTION_CANCELLED
*"      ACTION_FAILED
*"      BCONTACT_FAILED
*"----------------------------------------------------------------------


  data: l_rc            type sysubrc,
        l_no_formkey    type rfgen-kennzx,
        l_blocn         type blocn_kk,
        l_object_id     type toa_dara-object_id,
        ls_printparams  type eprintparams,
        ls_arc_index    type toa_dara,
        ls_arc_params   type arc_params,
        ls_dfkkcoh      type dfkkcoh,
        ls_fkkcoinfo    type fkkcoinfo,
        ls_recipient    type swotobjid,
        ls_bpc_obj      type bpc_obj,
        lt_objects      type bpc_obj occurs 1,
        lt_dfkkcoh      type dfkkcoh occurs  5 with header line,
        lt_dfkkcod      type dfkkcod occurs 10 with header line,
        lt_ranges1      like efg_ranges occurs 1 with header line,
        lt_ranges2      like efg_ranges occurs 1 with header line,
        lt_ranges3      like efg_ranges occurs 1 with header line,
        lt_ranges4      like efg_ranges occurs 1 with header line,
        lt_ranges5      like efg_ranges occurs 1 with header line,
        lt_ranges6      like efg_ranges occurs 1 with header line,
        lt_ranges7      like efg_ranges occurs 1 with header line,
        lt_ranges8      like efg_ranges occurs 1 with header line,
        lt_ranges9      like efg_ranges occurs 1 with header line.

  define ld_fkk_fld_2_container.
    add 1 to l_blocn.
    call function 'FKK_FLD_2_CONTAINER'
      exporting
        i_cotyp      = ls_dfkkcoh-cotyp
        i_cokey      = space
        i_bloid      = 'CNTR'
        i_blocn      = l_blocn
        i_entid      = &1
        i_structcont = &2
      importing
        e_dfkkcod    = lt_dfkkcod.
    append lt_dfkkcod.
  end-of-definition.

  define ld_fkk_fld_2_lt_objects.
    clear ls_bpc_obj.
    ls_bpc_obj-objtype = co_objtype_contract.
    ls_bpc_obj-objkey  = &1.
    append ls_bpc_obj to lt_objects.
  end-of-definition.

  define ld_fkk_fld_2_ranges.
    clear &2.
    if &1 is initial.
      &2-sign   = 'E'.
    else.
      &2-sign   = 'I'.
      &2-option = 'EQ'.
      &2-low    = &1.
    endif.
    append &2.
  end-of-definition.

* fill objects -> Ablage als Kontoinformation
  ls_arc_params-sap_object = co_objtype_account.
  ls_arc_params-ar_object  = co_doctype_account.
  ls_arc_index-object_id   = i_gpart.

  if not x_reprint is initial.
    clear: ls_arc_params-sap_object,
           ls_arc_params-ar_object.
  endif.

  ls_dfkkcoh-cotyp = 'ZCOTYP'.
  ls_dfkkcoh-spras = x_langu.
  ls_dfkkcoh-gpart = i_gpart.

* read addrdnumber
  clear ls_printparams.
  if x_formkey is initial  or
     not x_auswform is initial.
    clear l_no_formkey.
  else.
    l_no_formkey = 'X'.
    ls_printparams-formkey = x_formkey.
  endif.

  ls_printparams-formclass     = 'ZFORMCLASS'.
  ls_printparams-delayed_print = x_delayed_print.

  if ls_printparams-formkey is initial       or
     ls_printparams-delayed_print is initial or
     not x_auswform is initial.
    call function 'EFG_GET_PRINT_PARAMETERS'
      exporting
        x_printparams        = ls_printparams
        x_archive_bor_object = ls_arc_params-sap_object
        x_archive_arc_object = ls_arc_params-ar_object
        x_archive_object_id  = ls_arc_index-object_id
        x_no_delayed_print   = space
        x_no_formkey         = l_no_formkey
      importing
        y_printparams        = ls_printparams
        y_archive_index      = ls_arc_index
        y_archive_params     = ls_arc_params
        y_recipient          = ls_recipient
      exceptions
        cancelled            = 1
        input_error          = 2
        others               = 3.

    if sy-subrc = 1.
      mac_msg_putx co_msg_success 349 'EQ'
           space space space space action_cancelled.
      if 1 = 2.
        message s349(eq).
      endif.
      exit.
    elseif sy-subrc > 1.
      mac_msg_putx_wp co_msg_success 349 'EQ' space
                      space space space action_failed.
      if 1 = 2.
        message s349(eq) with space.
      endif.
      exit.
    endif.
  endif.
  y_formkey          = ls_printparams-formkey.
  ls_dfkkcoh-formkey = ls_printparams-formkey.
* create the header
  call function 'FKK_FLDS_2_HEADER'
    exporting
      i_cotyp       = ls_dfkkcoh-cotyp
      i_cokey       = space
      i_entid1      = '0001'
      i_structcont1 = i_gpart
      i_entid2      = '0002'
      i_structcont2 = i_anlage
      i_entid3      = '0003'
      i_structcont3 = i_form_typ
    changing
      c_dfkkcoh     = ls_dfkkcoh.
  refresh lt_dfkkcod.

* if delayed print is wanted, give data to container
  if ls_printparams-delayed_print = 'X'.
*   Felder in container
    ld_fkk_fld_2_container '0001' i_gpart.
    ld_fkk_fld_2_container '0002' i_anlage.
    ld_fkk_fld_2_container '0003' i_form_typ.
    ld_fkk_fld_2_container '0004' i_privat.
    ld_fkk_fld_2_container '0005' i_vende.
    ld_fkk_fld_2_container '0006' i_evbeginn.
    ld_fkk_fld_2_container '0007' i_evende.
    ld_fkk_fld_2_container '0008' i_an1_dat.
    ld_fkk_fld_2_container '0009' i_an2_dat.

    l_object_id = i_gpart.
    call function 'FKK_WRITE_CORR'
      exporting
        i_fkkcoinfo        = ls_fkkcoinfo
        i_object_id        = l_object_id
        i_avoid_sender_det = 'X'
      tables
        t_dfkkcod          = lt_dfkkcod
      changing
        c_dfkkcoh          = ls_dfkkcoh.
    mac_msg_putx co_msg_success 347 'EQ'
      space space space space space.
    if 1 = 2. message s347(eq). endif.
  else.
    call function 'FKK_WRITE_CORR'
      exporting
        i_fkkcoinfo        = ls_fkkcoinfo
        i_dont_write_to_db = 'X'
        i_avoid_sender_det = 'X'
      tables
        t_dfkkcod          = lt_dfkkcod
        t_dfkkcoh          = lt_dfkkcoh
      changing
        c_dfkkcoh          = ls_dfkkcoh.

*   Felder in lt_ranges
    ld_fkk_fld_2_ranges i_gpart    lt_ranges1.
    ld_fkk_fld_2_ranges i_anlage   lt_ranges2.
    ld_fkk_fld_2_ranges i_form_typ lt_ranges3.
    ld_fkk_fld_2_ranges i_privat   lt_ranges4.
    ld_fkk_fld_2_ranges i_vende    lt_ranges5.
    ld_fkk_fld_2_ranges i_evbeginn lt_ranges6.
    ld_fkk_fld_2_ranges i_evende   lt_ranges7.
    ld_fkk_fld_2_ranges i_an1_dat  lt_ranges8.
    ld_fkk_fld_2_ranges i_an2_dat  lt_ranges9.

    if ls_printparams-device is initial.
      ls_printparams-device = co_device_default.
    endif.
    loop at lt_dfkkcoh.
      call function 'EFG_PRINT_EXPANDED'
        exporting
          x_sendcontrol    = lt_dfkkcoh-sendcontrol
          x_rec_addr       = lt_dfkkcoh-adrnr
          x_rec_persnumber = lt_dfkkcoh-persnumber
          x_printparams    = ls_printparams
          x_archive_params = ls_arc_params
          x_archive_index  = ls_arc_index
          x_recipient      = ls_recipient
        importing
          y_printparams    = ls_printparams
        tables
          xt_ranges1       = lt_ranges1
          xt_ranges2       = lt_ranges2
          xt_ranges3       = lt_ranges3
          xt_ranges4       = lt_ranges4
          xt_ranges5       = lt_ranges5
          xt_ranges6       = lt_ranges6
          xt_ranges7       = lt_ranges7
          xt_ranges8       = lt_ranges8
          xt_ranges9       = lt_ranges9
        exceptions
          cancelled        = 6
          others           = 8.
      case syst-subrc.
        when 0.
        when 6.
          mac_msg_putx co_msg_success 120 'ZVM_EIGENT'
               space space space space action_cancelled.
          if 1 = 2.
            message s120(zvm_eigent).
          endif.
        when others.
          mac_msg_repeat co_msg_success action_failed.
      endcase.
    endloop.

    if sy-subrc = 0.
*     create customer contact for outgoing form
      clear l_rc.
      sort lt_dfkkcoh by gpart.
      delete adjacent duplicates from lt_dfkkcoh comparing gpart.
      loop at lt_dfkkcoh.
        check l_rc is initial.
        refresh lt_objects.
        ls_bpc_obj-objtype = co_objtype_partner.
        ls_bpc_obj-objkey  = i_gpart.
        append ls_bpc_obj to lt_objects.

*       Felder in lt_objects
        ld_fkk_fld_2_lt_objects i_vende.
        ld_fkk_fld_2_lt_objects i_evbeginn.
        ld_fkk_fld_2_lt_objects i_evende.
        ld_fkk_fld_2_lt_objects i_an1_dat.
        ld_fkk_fld_2_lt_objects i_an2_dat.

        call function 'BCONTACT_CREATE_FROM_FORM'
          exporting
            x_formkey      = ls_printparams-formkey
            x_formclass    = ls_printparams-formclass
            x_partner      = lt_dfkkcoh-gpart
          tables
            xt_objects     = lt_objects
          exceptions
            general_fault  = 1
            not_authorized = 2
            others         = 3.
        l_rc = sy-subrc.
      endloop.
      case l_rc.
        when 0.
          mac_msg_putx co_msg_success 119 'ZVM_EIGENT'
           space space space space space.
          if 1 = 2. message s119(zvm_eigent). endif.
        when 2.
          mac_msg_repeat co_msg_error bcontact_failed.
        when others.
          mac_msg_putx co_msg_programming_error 158 'EMV'
               space space space space bcontact_failed.
          if 1 = 2. message s158(emv). endif.
      endcase.
    endif.
  endif.
endfunction.
*FuBa zum Druckzeitpunkt
FUNCTION zvm_cs_mi_eigent_sample_z830.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(I_DFKKCOH) TYPE  DFKKCOH
*"     REFERENCE(I_ITCPO) TYPE  ITCPO
*"     REFERENCE(I_EFGPP) TYPE  EFG_PRINTPARAMS
*"     REFERENCE(I_ARCHIVE_PARAMS) TYPE  ARC_PARAMS
*"     REFERENCE(I_ARCHIVE_INDEX) TYPE  TOA_DARA
*"  TABLES
*"      T_FIMSG STRUCTURE  FIMSG
*"----------------------------------------------------------------------


  DATA: l_fld            TYPE fieldname,
        l_object_id      TYPE toa_dara-object_id,
        l_applk          TYPE fkkop-applk,
        ls_printparams   TYPE eprintparams,
        ls_arc_params    TYPE arc_params,
        ls_arc_index     TYPE toa_dara,
        ls_dfkkcohi      TYPE dfkkcohi,
        ls_bpc_obj       TYPE bpc_obj,
        lt_objects       TYPE bpc_obj OCCURS 1,
        lt_fkkcoi        TYPE fkkcoi OCCURS 10,
        lt_dfkkcod       TYPE dfkkcod OCCURS 10 WITH HEADER LINE,
        ls_ranges        TYPE efg_ranges,
        lt_rg_0001       TYPE efg_tab_ranges,
        lt_rg_0002       TYPE efg_tab_ranges,
        lt_rg_0003       TYPE efg_tab_ranges,
        lt_rg_0004       TYPE efg_tab_ranges,
        lt_rg_0005       TYPE efg_tab_ranges,
        lt_rg_0006       TYPE efg_tab_ranges,
        lt_rg_0007       TYPE efg_tab_ranges,
        lt_rg_0008       TYPE efg_tab_ranges,
        lt_rg_0009       TYPE efg_tab_ranges.

  FIELD-SYMBOLS     TYPE efg_tab_ranges.

  CALL FUNCTION 'FKK_READ_CORR'
    EXPORTING
      i_dfkkcoh  = i_dfkkcoh
    IMPORTING
      e_dfkkcohi = ls_dfkkcohi
    TABLES
      t_fkkcoi   = lt_fkkcoi
      t_dfkkcod  = lt_dfkkcod.

  REFRESH: lt_objects.

  LOOP AT lt_dfkkcod WHERE bloid = 'CNTR'.
    CONCATENATE 'LT_RG_' lt_dfkkcod-entid INTO l_fld.
    ASSIGN (l_fld) TO .
    IF sy-subrc = 0.
      CLEAR: ls_ranges,
             .
      IF lt_dfkkcod-cdata IS INITIAL OR
         lt_dfkkcod-cdata = '00000000'.
        ls_ranges-sign   = 'E'.
      ELSE.
        ls_ranges-sign   = 'I'.
        ls_ranges-option = 'EQ'.
        ls_ranges-low    =  lt_dfkkcod-cdata.
      ENDIF.
      APPEND ls_ranges TO .
    ENDIF.

    ls_bpc_obj-objtype = co_objtype_contract.
    ls_bpc_obj-objkey  = lt_dfkkcod-cdata.
    APPEND ls_bpc_obj TO lt_objects.
  ENDLOOP.

  MOVE-CORRESPONDING i_efgpp TO ls_printparams.
  MOVE-CORRESPONDING i_itcpo TO ls_printparams.
  ls_printparams-formkey   = i_dfkkcoh-formkey.
  ls_printparams-formclass = 'ZFORMCLASS'.
  ls_printparams-langu     = i_dfkkcoh-spras.
  IF ls_printparams-device IS INITIAL.
    ls_printparams-device = co_device_default.
  ENDIF.

  CALL FUNCTION 'EFG_PRINT_EXPANDED'
    EXPORTING
      x_sendcontrol    = i_dfkkcoh-sendcontrol
      x_rec_addr       = i_dfkkcoh-adrnr
      x_rec_persnumber = i_dfkkcoh-persnumber
      x_printparams    = ls_printparams
      x_archive_params = i_archive_params
      x_archive_index  = i_archive_index
    TABLES
      xt_ranges1       = lt_rg_0001
      xt_ranges2       = lt_rg_0002
      xt_ranges3       = lt_rg_0003
      xt_ranges4       = lt_rg_0004
      xt_ranges5       = lt_rg_0005
      xt_ranges6       = lt_rg_0006
      xt_ranges7       = lt_rg_0007
      xt_ranges8       = lt_rg_0008
      xt_ranges9       = lt_rg_0009
    EXCEPTIONS
      OTHERS           = 8.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH
                 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
  ENDIF.

* create customer contact for outgoing form
  ls_bpc_obj-objtype = co_objtype_partner.
  ls_bpc_obj-objkey  = i_dfkkcoh-data1.
  APPEND ls_bpc_obj TO lt_objects.

  CALL FUNCTION 'FKK_GET_APPLICATION'
    EXPORTING
      i_no_dialog = 'X'
    IMPORTING
      e_applk     = l_applk.

  IF l_applk = 'R'       AND
     i_dfkkcoh-xtest IS INITIAL.
    REFRESH lt_objects.
    ls_bpc_obj-objtype = co_objtype_partner.
    ls_bpc_obj-objkey  = i_dfkkcoh-data1.
    APPEND ls_bpc_obj TO lt_objects.
    CALL FUNCTION 'BCONTACT_CREATE_FROM_FORM'
      EXPORTING
        x_formkey      = ls_printparams-formkey
        x_formclass    = ls_printparams-formclass
        x_partner      = i_dfkkcoh-gpart
*       X_ALTPARTNER   =                      "leave empty!
      TABLES
        xt_objects     = lt_objects
      EXCEPTIONS
        general_fault  = 1
        not_authorized = 2
        OTHERS         = 3.
    IF sy-subrc NE 0.
      MOVE-CORRESPONDING sy TO t_fimsg.
      APPEND t_fimsg.
    ENDIF.
  ENDIF.
ENDFUNCTION.