Tuesday, 9 May 2017

COPA Report Avg Rate and Budget Rate Enhancement to RUN COPA for Project Profitability.



Tcode Used :

1.KEPM is used  maintain planning Levels for different Plan version

Average Rate and Budgeted rate we maintained in custom table and from there it picks in COPA planning through custom enhancement. So average and budgeted rate is not part of config process hence not possible to include in config document. 

https://blogs.sap.com/2013/09/26/copa-planning/




User Exit: EXIT_SAPLKEP5_002-Customer-Specific CO-PA Planning Functions with Reference Data

*&---------------------------------------------------------------------*
*&  Include           ZXKKEU10
*&---------------------------------------------------------------------*

datalth_ce0_reference like ce0ctml occurs with header line.
datalt_ce0     type table of ce0ctml,
      ls_ce0     type ce0ctml,
      lt_ce0_ref type table of ce0ctml,
      ls_ce0_ref type ce0ctml.
datalt_rates type table of zco_rates_new,
      ls_rates type zco_rates_new.
datalv_yr(4type c.
data lv_pr(3type c.

lt_ce0[] ith_ce0_reference[].
lt_ce0_ref[] xth_ce0[].
lth_ce0_reference[] ith_ce0_reference[].

if i_exitnr eq 101.  ""Planned Step ID

  loop at xth_ce0 into ls_ce0.
*    IF LS_CE0-PERIO LE IS_PLANNING_EXIT-PERIOTO.
    read table lth_ce0_reference into ls_ce0_ref with key perio ls_ce0-perio.
    if sy-subrc eq 0.
      lv_yr ls_ce0_ref-perio+0(4)""Year
      lv_pr ls_ce0_ref-perio+4(3)""Period
*******    Custom Table for Maintain Rates for Bedgeted rate
      select single from zco_rates_new into ls_rates where bukrs ls_ce0-bukrs and gjahr lv_yr and period lv_pr.
      if ls_rates-bgt_rate is not   initial.
        ls_ce0-vv010 ls_ce0_ref-vv010 / ls_rates-bgt_rate.
        ls_ce0-vv011 ls_ce0_ref-vv011 / ls_rates-bgt_rate.
        ls_ce0-vv012 ls_ce0_ref-vv012 / ls_rates-bgt_rate.
        ls_ce0-vv030 ls_ce0_ref-vv030 / ls_rates-bgt_rate.
        ls_ce0-vv050 ls_ce0_ref-vv050 / ls_rates-bgt_rate.
        ls_ce0-vv070 ls_ce0_ref-vv070 / ls_rates-bgt_rate.
        ls_ce0-vv100 ls_ce0_ref-vv100 / ls_rates-bgt_rate.
        ls_ce0-vv120 ls_ce0_ref-vv120 / ls_rates-bgt_rate.
        ls_ce0-vv130 ls_ce0_ref-vv130 / ls_rates-bgt_rate.
        ls_ce0-vv150 ls_ce0_ref-vv150 / ls_rates-bgt_rate.
        ls_ce0-vv170 ls_ce0_ref-vv170 / ls_rates-bgt_rate.
        ls_ce0-vv180 ls_ce0_ref-vv180 / ls_rates-bgt_rate.
        ls_ce0-vv051 ls_ce0_ref-vv051 / ls_rates-bgt_rate.
        ls_ce0-vv052 ls_ce0_ref-vv052 / ls_rates-bgt_rate.
        ls_ce0-vv031 ls_ce0_ref-vv031 / ls_rates-bgt_rate.
        ls_ce0-vv032 ls_ce0_ref-vv032 / ls_rates-bgt_rate.
        ls_ce0-vv033 ls_ce0_ref-vv033 / ls_rates-bgt_rate.
        ls_ce0-vv034 ls_ce0_ref-vv034 / ls_rates-bgt_rate.
        ls_ce0-vv035 ls_ce0_ref-vv035 / ls_rates-bgt_rate.
        ls_ce0-vv036 ls_ce0_ref-vv036 / ls_rates-bgt_rate.
        ls_ce0-vv037 ls_ce0_ref-vv037 / ls_rates-bgt_rate.
        ls_ce0-vv038 ls_ce0_ref-vv038 / ls_rates-bgt_rate.
        ls_ce0-vv039 ls_ce0_ref-vv039 / ls_rates-bgt_rate.
        ls_ce0-vv190 ls_ce0_ref-vv190 / ls_rates-bgt_rate.
        ls_ce0-vv071 ls_ce0_ref-vv071 / ls_rates-bgt_rate.
        ls_ce0-vv072 ls_ce0_ref-vv072 / ls_rates-bgt_rate.
        ls_ce0-vv073 ls_ce0_ref-vv073 / ls_rates-bgt_rate.
        ls_ce0-vv074 ls_ce0_ref-vv074 / ls_rates-bgt_rate.
        ls_ce0-vv075 ls_ce0_ref-vv075 / ls_rates-bgt_rate.
        ls_ce0-vv076 ls_ce0_ref-vv076 / ls_rates-bgt_rate.
        ls_ce0-vv077 ls_ce0_ref-vv077 / ls_rates-bgt_rate.
        ls_ce0-vv091 ls_ce0_ref-vv091 / ls_rates-bgt_rate.
        ls_ce0-vv092 ls_ce0_ref-vv092 / ls_rates-bgt_rate.
        ls_ce0-vv093 ls_ce0_ref-vv093 / ls_rates-bgt_rate.
        ls_ce0-vv101 ls_ce0_ref-vv101 / ls_rates-bgt_rate.
        ls_ce0-vv102 ls_ce0_ref-vv102 / ls_rates-bgt_rate.
        ls_ce0-vv103 ls_ce0_ref-vv103 / ls_rates-bgt_rate.
        ls_ce0-vv104 ls_ce0_ref-vv104 / ls_rates-bgt_rate.
        ls_ce0-vv105 ls_ce0_ref-vv105 / ls_rates-bgt_rate.
        ls_ce0-vv111 ls_ce0_ref-vv111 / ls_rates-bgt_rate.
        ls_ce0-vv112 ls_ce0_ref-vv112 / ls_rates-bgt_rate.
        ls_ce0-vv113 ls_ce0_ref-vv113 / ls_rates-bgt_rate.
        ls_ce0-vv121 ls_ce0_ref-vv121 / ls_rates-bgt_rate.
        ls_ce0-vv122 ls_ce0_ref-vv122 / ls_rates-bgt_rate.
        ls_ce0-vv131 ls_ce0_ref-vv131 / ls_rates-bgt_rate.
        ls_ce0-vv132 ls_ce0_ref-vv132 / ls_rates-bgt_rate.
        ls_ce0-vv133 ls_ce0_ref-vv133 / ls_rates-bgt_rate.
        ls_ce0-vv134 ls_ce0_ref-vv134 / ls_rates-bgt_rate.
        ls_ce0-vv135 ls_ce0_ref-vv135 / ls_rates-bgt_rate.
        ls_ce0-vv151 ls_ce0_ref-vv151 / ls_rates-bgt_rate.
        ls_ce0-vv152 ls_ce0_ref-vv152 / ls_rates-bgt_rate.
        ls_ce0-vv153 ls_ce0_ref-vv153 / ls_rates-bgt_rate.
        ls_ce0-vv154 ls_ce0_ref-vv154 / ls_rates-bgt_rate.
        ls_ce0-vv155 ls_ce0_ref-vv155 / ls_rates-bgt_rate.
        ls_ce0-vv171 ls_ce0_ref-vv171 / ls_rates-bgt_rate.
        ls_ce0-vv172 ls_ce0_ref-vv172 / ls_rates-bgt_rate.
        ls_ce0-vv173 ls_ce0_ref-vv173 / ls_rates-bgt_rate.
        ls_ce0-vv174 ls_ce0_ref-vv174 / ls_rates-bgt_rate.
        ls_ce0-vv175 ls_ce0_ref-vv175 / ls_rates-bgt_rate.
        ls_ce0-vv176 ls_ce0_ref-vv176 / ls_rates-bgt_rate.
        ls_ce0-vv177 ls_ce0_ref-vv177 / ls_rates-bgt_rate.
        ls_ce0-vv178 ls_ce0_ref-vv178 / ls_rates-bgt_rate.
        ls_ce0-vv179 ls_ce0_ref-vv179 / ls_rates-bgt_rate.
        ls_ce0-vv181 ls_ce0_ref-vv181 / ls_rates-bgt_rate.
        ls_ce0-vv182 ls_ce0_ref-vv182 / ls_rates-bgt_rate.
        ls_ce0-vv183 ls_ce0_ref-vv183 / ls_rates-bgt_rate.
        ls_ce0-vv191 ls_ce0_ref-vv191 / ls_rates-bgt_rate.
        modify xth_ce0 from ls_ce0.
      endif.

    endif.
    clear:ls_rates,ls_ce0,ls_ce0_ref,lv_pr,lv_yr.
  endloop.

elseif i_exitnr eq 100.  ""Actual Step ID

  loop at xth_ce0 into ls_ce0.
*    IF LS_CE0-PERIO LE IS_PLANNING_EXIT-PERIOTO.
    read table lth_ce0_reference into ls_ce0_ref with key perio ls_ce0-perio.
    if sy-subrc eq 0.
      lv_yr ls_ce0_ref-perio+0(4)""Year
      lv_pr ls_ce0_ref-perio+4(3)""Period
*******    Custom Table for Maintain Rates for Actula Rate
      select single from zco_rates_new into ls_rates where bukrs ls_ce0-bukrs and gjahr lv_yr and period lv_pr.
      if ls_rates-avg_rate is not   initial.
        ls_ce0-vv010 ls_ce0_ref-vv010 / ls_rates-avg_rate.
        ls_ce0-vv011 ls_ce0_ref-vv011 / ls_rates-avg_rate.
        ls_ce0-vv012 ls_ce0_ref-vv012 / ls_rates-avg_rate.
        ls_ce0-vv030 ls_ce0_ref-vv030 / ls_rates-avg_rate.
        ls_ce0-vv050 ls_ce0_ref-vv050 / ls_rates-avg_rate.
        ls_ce0-vv070 ls_ce0_ref-vv070 / ls_rates-avg_rate.
        ls_ce0-vv100 ls_ce0_ref-vv100 / ls_rates-avg_rate.
        ls_ce0-vv120 ls_ce0_ref-vv120 / ls_rates-avg_rate.
        ls_ce0-vv130 ls_ce0_ref-vv130 / ls_rates-avg_rate.
        ls_ce0-vv150 ls_ce0_ref-vv150 / ls_rates-avg_rate.
        ls_ce0-vv170 ls_ce0_ref-vv170 / ls_rates-avg_rate.
        ls_ce0-vv180 ls_ce0_ref-vv180 / ls_rates-avg_rate.
        ls_ce0-vv051 ls_ce0_ref-vv051 / ls_rates-avg_rate.
        ls_ce0-vv052 ls_ce0_ref-vv052 / ls_rates-avg_rate.
        ls_ce0-vv031 ls_ce0_ref-vv031 / ls_rates-avg_rate.
        ls_ce0-vv032 ls_ce0_ref-vv032 / ls_rates-avg_rate.
        ls_ce0-vv033 ls_ce0_ref-vv033 / ls_rates-avg_rate.
        ls_ce0-vv034 ls_ce0_ref-vv034 / ls_rates-avg_rate.
        ls_ce0-vv035 ls_ce0_ref-vv035 / ls_rates-avg_rate.
        ls_ce0-vv036 ls_ce0_ref-vv036 / ls_rates-avg_rate.
        ls_ce0-vv037 ls_ce0_ref-vv037 / ls_rates-avg_rate.
        ls_ce0-vv038 ls_ce0_ref-vv038 / ls_rates-avg_rate.
        ls_ce0-vv039 ls_ce0_ref-vv039 / ls_rates-avg_rate.
        ls_ce0-vv190 ls_ce0_ref-vv190 / ls_rates-avg_rate.
        ls_ce0-vv071 ls_ce0_ref-vv071 / ls_rates-avg_rate.
        ls_ce0-vv072 ls_ce0_ref-vv072 / ls_rates-avg_rate.
        ls_ce0-vv073 ls_ce0_ref-vv073 / ls_rates-avg_rate.
        ls_ce0-vv074 ls_ce0_ref-vv074 / ls_rates-avg_rate.
        ls_ce0-vv075 ls_ce0_ref-vv075 / ls_rates-avg_rate.
        ls_ce0-vv076 ls_ce0_ref-vv076 / ls_rates-avg_rate.
        ls_ce0-vv077 ls_ce0_ref-vv077 / ls_rates-avg_rate.
        ls_ce0-vv091 ls_ce0_ref-vv091 / ls_rates-avg_rate.
        ls_ce0-vv092 ls_ce0_ref-vv092 / ls_rates-avg_rate.
        ls_ce0-vv093 ls_ce0_ref-vv093 / ls_rates-avg_rate.
        ls_ce0-vv101 ls_ce0_ref-vv101 / ls_rates-avg_rate.
        ls_ce0-vv102 ls_ce0_ref-vv102 / ls_rates-avg_rate.
        ls_ce0-vv103 ls_ce0_ref-vv103 / ls_rates-avg_rate.
        ls_ce0-vv104 ls_ce0_ref-vv104 / ls_rates-avg_rate.
        ls_ce0-vv105 ls_ce0_ref-vv105 / ls_rates-avg_rate.
        ls_ce0-vv111 ls_ce0_ref-vv111 / ls_rates-avg_rate.
        ls_ce0-vv112 ls_ce0_ref-vv112 / ls_rates-avg_rate.
        ls_ce0-vv113 ls_ce0_ref-vv113 / ls_rates-avg_rate.
        ls_ce0-vv121 ls_ce0_ref-vv121 / ls_rates-avg_rate.
        ls_ce0-vv122 ls_ce0_ref-vv122 / ls_rates-avg_rate.
        ls_ce0-vv131 ls_ce0_ref-vv131 / ls_rates-avg_rate.
        ls_ce0-vv132 ls_ce0_ref-vv132 / ls_rates-avg_rate.
        ls_ce0-vv133 ls_ce0_ref-vv133 / ls_rates-avg_rate.
        ls_ce0-vv134 ls_ce0_ref-vv134 / ls_rates-avg_rate.
        ls_ce0-vv135 ls_ce0_ref-vv135 / ls_rates-avg_rate.
        ls_ce0-vv151 ls_ce0_ref-vv151 / ls_rates-avg_rate.
        ls_ce0-vv152 ls_ce0_ref-vv152 / ls_rates-avg_rate.
        ls_ce0-vv153 ls_ce0_ref-vv153 / ls_rates-avg_rate.
        ls_ce0-vv154 ls_ce0_ref-vv154 / ls_rates-avg_rate.
        ls_ce0-vv155 ls_ce0_ref-vv155 / ls_rates-avg_rate.
        ls_ce0-vv171 ls_ce0_ref-vv171 / ls_rates-avg_rate.
        ls_ce0-vv172 ls_ce0_ref-vv172 / ls_rates-avg_rate.
        ls_ce0-vv173 ls_ce0_ref-vv173 / ls_rates-avg_rate.
        ls_ce0-vv174 ls_ce0_ref-vv174 / ls_rates-avg_rate.
        ls_ce0-vv175 ls_ce0_ref-vv175 / ls_rates-avg_rate.
        ls_ce0-vv176 ls_ce0_ref-vv176 / ls_rates-avg_rate.
        ls_ce0-vv177 ls_ce0_ref-vv177 / ls_rates-avg_rate.
        ls_ce0-vv178 ls_ce0_ref-vv178 / ls_rates-avg_rate.
        ls_ce0-vv179 ls_ce0_ref-vv179 / ls_rates-avg_rate.
        ls_ce0-vv181 ls_ce0_ref-vv181 / ls_rates-avg_rate.
        ls_ce0-vv182 ls_ce0_ref-vv182 / ls_rates-avg_rate.
        ls_ce0-vv183 ls_ce0_ref-vv183 / ls_rates-avg_rate.
        ls_ce0-vv191 ls_ce0_ref-vv191 / ls_rates-avg_rate.
        modify xth_ce0 from ls_ce0.
      endif.

    endif.
    clear:ls_rates,ls_ce0,ls_ce0_ref,lv_pr,lv_yr.
  endloop.
endif.


KE30 to KE35 - for COPA Report layout Creation.
Kei2 -Value field and Costelement mapping in PA trasfer Structure.
oko6 - Allocation Structures.
FB08 - Posting Document Reversal.



************************************************************************
User manual - Closing activities for CTML

Document contains 13 Transaction codes which are as follows.
1. KP46 – Head/Seat/User count updation into SAP
2. KSU5 – Indirect Cost allocation between CC to Alloc. CC
3. S_ALR_87013611 – To check for Under/Over absorption cost details before allocation.
4. CPTL – Project/WBS/Network – Actual template alloc.
5. KSS2 – Actual Cost Splitting
6. KSII – Execute Actual Price Calculation
7. ZCO_01 – Manual Actual price cost centers  (custom programe to update KBK6 Tcode)
8. CJN2 – Reval. At Actual prices – Proj/WBS/NW
9. KEU5 – Execute Actual Assessment.
10. CJ8G – Actual Settlement – Proj/WBS/NW
11. KEPM – Planning Frame work
12. KE30 – Run Profitability
13. CJI3 – Check the balances between WBS & report.

BDC for KBK6  UPLOAD

report zco_actual_activity_rates.

types:   begin of gty_error,
           row type i,
           ind type char2,
           mes type string,
         end of gty_error.
data:lt_cost type table of cost,
     ls_cost type cost,
     lt_cssl type table of cssl,
     ls_cssl type cssl.

datal_mstring(480).
data:   bdcdata like bdcdata    occurs with header line.
data:   messtab like bdcmsgcoll occurs with header line.
data:  gs_error type gty_error,
       gt_error type standard table of gty_error.

data gv_row     type i.
*----------------------------------------------------------------------*
*           Selection Screen                                           *
*----------------------------------------------------------------------*
selection-screen begin of block b1 with frame title text-001.
parameters p_period type perbl obligatory,
             p_year   type cost-gjahr obligatory,
             p_cost TYPE cssl-kostl.
selection-screen end of block b1.

*----------------------------------------------------------------------*


start-of-selection.
**********To Get CO Object: Price Totals
  case p_period.
    when '001'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg001 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '002'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg002 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '003'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg003 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '004'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg004 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '005'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg005 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '006'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg006 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '007'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg007 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '008'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg008 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '009'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg009 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '010'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg010 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '011'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg011 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
    when '012'.
      select from cost into table lt_cost where gjahr eq p_year and tarkz eq '005' and tkg012 eq '0'"#EC CI_NOFIRST
      if sy-subrc 0.
        sort lt_cost .
      endif.
  endcase.



  if lt_cost is not initial.
************  to Get all  Cost Center/Activity Type
    select from cssl into table lt_cssl for all entries in lt_cost where objnr lt_cost-objnr and gjahr eq p_year.
    if sy-subrc 0.
      sort lt_cssl.
    endif.

    if p_cost IS NOT INITIAL .
      DELETE lt_cssl where kostl ne p_cost.
      endif.
*  endif.
**BREAK-POINT.
*  if lt_cssl is not initial .

    loop at lt_cssl into ls_cssl.

*     if lv_sno eq 1.

      perform bdc_dynpro      using 'SAPLSPO4' '0300'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'SVALD-VALUE(01)'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=FURT'.
      perform bdc_field       using 'SVALD-VALUE(01)'
                              ls_cssl-kokrs."      '1000'.
      perform bdc_transaction using 'OKKS'.


*        perform bdc_dynpro      using 'SAPLSPO4' '0300'.
*        perform bdc_field       using 'BDC_CURSOR'
*                                      'SVALD-VALUE(01)'.
*        perform bdc_field       using 'BDC_OKCODE'
*                                      '=FURT'.
*        perform bdc_field       using 'SVALD-VALUE(01)'
*                                      ls_cssl-kokrs."'ctml'.
*      endif.

      perform bdc_dynpro      using 'SAPLKPP0' '1000'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'KPP0B-VALUE(08)'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=CSPB'.
      perform bdc_field       using 'KPP1B-ONLY'
                                    'X'.
      perform bdc_field       using 'KPP0B-VALUE(01)'
                                    p_period."'1'. "Period
      perform bdc_field       using 'KPP0B-VALUE(02)'
                                    p_period."'1'. "Period
      perform bdc_field       using 'KPP0B-VALUE(03)'
                                    p_year."'2017'. "Year
      perform bdc_field       using 'KPP0B-VALUE(05)'
                                    ls_cssl-kostl."'ASNAIN10'.""CostCenter
      perform bdc_field       using 'KPP0B-VALUE(07)'
                                        ''.                                "Cost Group
      perform bdc_field       using 'KPP0B-VALUE(08)'
                                    ls_cssl-lstar."'1001'."Activity Type
      perform bdc_field       using 'KPP0B-VALUE(10)'
                                        ''.                                  "Activity Group.
      perform bdc_dynpro      using 'SAPLKPP2' '0110'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'Z-BDC06(01)'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '/00'.
      perform bdc_field       using 'Z-BDC03(01)'
                                    '0.01'.
      perform bdc_field       using 'Z-BDC06(01)'
                                    '     10000'.
      perform bdc_dynpro      using 'SAPLKPP2' '0110'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'Z-BDC06(01)'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=CBUC'.
      perform bdc_transaction using 'KBK6'.

      clear:ls_cssl.
    endloop.

  else.
    message text-003 type 'S'.
  endif.


end-of-selection.

  if gt_error is not initial.
    perform display.
  endif.

  refresh:messtab,bdcdata,gt_error.
  clear:p_year,p_period.


















form bdc_transaction  using tcode.


  data ls_ctu type ctu_params.

  ls_ctu-dismode 'N'.
  ls_ctu-updmode 'S'.
  ls_ctu-defsize 'X'.
  clear messtab[].

  if tcode eq 'OKKS'.
    call transaction tcode using bdcdata
                        options from ls_ctu
                        messages into messtab.
  else.
    call transaction tcode using bdcdata
                        options from ls_ctu
                        messages into messtab.
    commit work.
    gv_row gv_row + 1.
    if messtab[] is not initial.
      loop at messtab.
        message id     messtab-msgid
                type   messtab-msgtyp
                number messtab-msgnr
                into l_mstring
                with messtab-msgv1
                     messtab-msgv2
                     messtab-msgv3
                     messtab-msgv4.
        gs_error-row gv_row.
        gs_error-ind messtab-msgtyp.
        gs_error-mes l_mstring.
        append gs_error to gt_error.
      endloop.
    else.
      gs_error-row gv_row.
      gs_error-ind 'S'.
      gs_error-mes 'Successfuly Posted'.
      append gs_error to gt_error.
    endif.
  endif.
  clear bdcdatabdcdata[].
endform.                    " BDC_TRANSACTION
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form display .

  data lo_alv       type ref to cl_salv_table,
         lo_functions type ref to cl_salv_functions,
         lo_columns   type ref to cl_salv_columns_table,
         lo_column    type ref to cl_salv_column_table.
  try.
      call method cl_salv_table=>factory
        importing
          r_salv_table lo_alv
        changing
          t_table      gt_error.
    catch cx_salv_msg.
  endtry.
  lo_functions lo_alv->get_functions).
  lo_functions->set_allabap_true ).

  call method lo_alv->get_columns
    receiving
      value lo_columns.

*to change the name of the column in ALV.
  try.
      lo_column ?= lo_columns->get_column'ROW' ).
    catch cx_salv_not_found.
  endtry.
  lo_column->set_long_text'Row ID' ).
  lo_column->set_medium_text'Row ID' ).
  lo_column->set_short_text'Row ID' ).
  try.
      lo_column ?= lo_columns->get_column'IND' ).
    catch cx_salv_not_found.
  endtry.
  lo_column->set_long_text'Indicator' ).
  lo_column->set_medium_text'Indicator' ).
  lo_column->set_short_text'Indicator' ).
  try.
      lo_column ?= lo_columns->get_column'MES' ).
    catch cx_salv_not_found.
  endtry.
  lo_column->set_long_text'Message' ).
  lo_column->set_medium_text'Message' ).
  lo_column->set_short_text'Message' ).

  call method lo_alv->display.

endform.





*----------------------------------------------------------------------*
*        Start new screen                                              *
**----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
  clear bdcdata.
  bdcdata-program  program.
  bdcdata-dynpro   dynpro.
  bdcdata-dynbegin 'X'.
  append bdcdata.
endform.

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
*  IF FVAL <> NODATA.
  clear bdcdata.
  bdcdata-fnam fnam.
  bdcdata-fval fval.
  append bdcdata.
*  ENDIF.
endform.

No comments:

Post a Comment