Wednesday, 31 January 2024

Upload File From Server

 


Types : begin of itab1,
        rec(1000type c,
        end of itab1.

data  itab type table of itab1.
data  wa type itab1.

  refresh itab.
  clear itab.
  if p_fname is not initial.  "This Option not use

    message 'Can Not Select File, Only For Background' type 'E'.

    p_file  p_fname+7(53).

    replace all occurrences of '\' in p_file with '/'.
    concatenate '/sapinterface/N' p_file into p_file.

*   For Test Location only
    replace all occurrences of 'QAS' in p_file with ''.

    w_flname p_file+36(25).

    open dataset p_file
    for input in text mode encoding default ."WITH WINDOWS LINEFEED.

    if sy-subrc <> 0.
*    MESSAGE XXX WITH v_file.
    endif.

    do.
      read dataset p_file into wa.
      if sy-subrc <> 0.
        exit.
      endif.

      replace all occurrences of cl_abap_char_utilities=>cr_lf(1in wa with space.

      concatenate wa ';' w_flname into wa.
      append wa to itab.
    enddo.

    close dataset p_file.

Monday, 29 January 2024

IW32 - Change user and system Status - Using BAPI

 




datait_status type table of jstat,
        wa_status type jstat.

*Teco Complete
  refresh lt_methods.
  clear ls_methods.

  ls_methods-refnumber  1.                   "Reference number
  ls_methods-method     'TECHNICALCOMPLETE'"Method
  ls_methods-objecttype 'HEADER'.        "Object type
  ls_methods-objectkey  =  g_aufnr.
  append  ls_methods to lt_methods..

  clear ls_methods.
  ls_methods-refnumber  1.                  " <--- This has changed
  ls_methods-method     'SAVE'.               "Method
  ls_methods-objectkey  g_aufnr.
  append  ls_methods to lt_methods.

  refresh lt_header[].
  clear ls_header.

  ls_header-orderid    g_aufnr.
  ls_header-order_type g_ord_type.
  ls_header-planplant  '2000'.
  ls_header-bus_area   g_bus_area.
  ls_header-mn_wk_ctr  g_wrkctr.
  append ls_header to lt_header.


  refresh  lt_return[].
  call function 'BAPI_ALM_ORDER_MAINTAIN'
    tables
      it_methods lt_methods
      it_header  lt_header
      return     lt_return.

  call function 'BAPI_TRANSACTION_COMMIT'
    exporting
      wait 'X'.

  wait up to seconds.

********************************************************************
*  Bloc.
  clear objnr.
  concatenate 'OR' g_aufnr into objnr.

  clear wa_status.
  refresh it_status.
  wa_status-stat =  'E0018'.
  wa_status-inact 'X'.
  append wa_status to it_status.

  wa_status-stat =  'E0021'.
  wa_status-inact 'X'.
  append wa_status to it_status.

  wa_status-stat =  'E0020'.
  wa_status-inact ''.
  append wa_status to it_status.


  loop at it_status into wa_status.
    call function 'STATUS_CHANGE_EXTERN'
     exporting
      client                    sy-mandt
      objnr                     objnr
      user_status               wa_status-stat
      set_inact                 wa_status-inact
    importing
      stonr                     t_stone
* EXCEPTIONS
*   OBJECT_NOT_FOUND          = 1
*   STATUS_INCONSISTENT       = 2
*   STATUS_NOT_ALLOWED        = 3
*   OTHERS                    = 4
    .
  endloop.

  call function 'BAPI_TRANSACTION_COMMIT'
    exporting
      wait 'X'.

  wait up to seconds.








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.



 

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...