Showing posts with label BDC. Show all posts
Showing posts with label BDC. Show all posts

Monday, 29 January 2024

DP90 - BDC



constants c_space type value cl_abap_char_utilities=>horizontal_tab.

  refresh it_messtab.
  concatenate  sy-datum+6(2sy-datum+4(2)
               sy-datum(4into g_date separated by '.'.

  perform bdc_dynpro      using 'SAPLVPK_GUI_INTRO' '0300'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RV45S-BSTNK'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=SAVE_BI'.
  perform bdc_field       using 'AUFK-AUFNR' g_aufnr.
  perform bdc_field       using 'VPK_INPUT_SELECTION-VBELN' c_space.
  perform bdc_field       using 'G_BUDAT'   g_date.
  perform bdc_transaction using 'DP90'.

  commit work.

*  MESSAGE '' TYPE 'S'.

*   CONCATENATE G_AUFNR 'Created' INTO G_MESS separated by Space.

  if sy-subrc eq 0.
    clear g_vbeln.
    loop at it_messtab where msgtyp 'S' and msgv1(1'3'.
      g_vbeln it_messtab-msgv1.
    endloop.
  endif.



 

Thursday, 25 January 2024

ME52N Change PR - BDC

 


 refresh it_pr.
  select ebkn~banfn
         ebkn~bnfpo
         ebkn~sakto
         ebkn~aufnr
*         AFVC~LTXA1
*         AFVC~BEDNR
    into corresponding fields of table it_pr
    from ebkn
    where ebkn~aufnr g_aufnr.

*Get Cost Center
  sort it_dat by col_02 col_09.
  sort it_pr by ltxa1 bednr.
  loop at it_pr into wa_pr.
    read table it_dat2 into wa_dat2 with key col_02 wa_pr-ltxa1
*                                             col_09 = wa_pr-BEDNR
                                             binary search.
    if sy-subrc eq 0.
      wa_pr-kostl wa_dat2-col_16.
    endif.
    modify it_pr from wa_pr.
  endloop.

*  Split data.
  it_pr1[] it_pr[].
  delete adjacent duplicates from it_pr comparing banfn.

  clear g_banfn.
  loop at it_pr into wa_pr.
    g_banfn wa_pr-banfn.
  endloop.

  loop at it_pr into wa_pr.
    perform bdc_dynpro      using 'SAPLMEGUI' '0014'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=MECHOB'.
    perform bdc_field       using 'DYN_6000-LIST'
                                  '   1'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MEREQ3319-MATNR'.
    perform bdc_dynpro      using 'SAPLMEGUI' '0002'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=MEOK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MEPO_SELECT-BANFN'.
    perform bdc_field       using 'MEPO_SELECT-BANFN'    wa_pr-banfn.
    perform bdc_field       using 'MEPO_SELECT-BSTYP_B'
                                  'X'.
    perform bdc_dynpro      using 'SAPLMEGUI' '0014'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=MEV4001BUTTON'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'DYN_6000-LIST'.
    perform bdc_field       using 'DYN_6000-LIST'
                                  '   1'.
    perform bdc_dynpro      using 'SAPLMEGUI' '0014'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TABREQDT6'.
    perform bdc_field       using 'DYN_6000-LIST'
                                  '   1'.

    loop at it_pr1 into wa_pr1.
      perform bdc_dynpro      using 'SAPLMEGUI' '0014'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '=FORWARD3200'.
      perform bdc_field       using 'DYN_6000-LIST'
                                    '   1'.
      perform bdc_field       using 'MEACCT1100-SAKTO'
                                    '41310-0000'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'COBL-KOSTL'.
      perform bdc_field       using 'COBL-KOSTL'     wa_pr1-kostl.
    endloop.

    perform bdc_dynpro      using 'SAPLMEGUI' '0014'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=MESAVE'.
    perform bdc_transaction using 'ME52N'.
  endloop.





 

IW32 Change User Status SVO - BDC

 


wait up to seconds.

  data objnr like  jsto-objnr.
  data stat like    jstat-stat.
  data  t_stone like  tj30-stonr.

  concatenate 'OR' g_aufnr into objnr.
  stat 'E0018'.

  call function 'STATUS_CHANGE_EXTERN'
    exporting
*   CHECK_ONLY                = ' '
     client                    sy-mandt
      objnr                     objnr
      user_status               stat
      set_inact                 'X'
*   SET_CHGKZ                 =
*   NO_CHECK                  = ' '
   importing
     stonr                     t_stone
* EXCEPTIONS
*   OBJECT_NOT_FOUND          = 1
*   STATUS_INCONSISTENT       = 2
*   STATUS_NOT_ALLOWED        = 3
*   OTHERS                    = 4
            .
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

  call function 'BAPI_TRANSACTION_COMMIT'
    exporting
      wait 'X'.

  wait up to seconds.

Visitor

Code Syntax Try...Endtry

  Code : Report Try. Parameters  NUMBER  type  I . data  RESULT  type  P  decimals  2 . data  OREF  type  ref  to  CX_ROOT . data  TEXT  typ...