Geschützt: Adding new line items to an Inbound delivery (with PO reference)

Dieser Inhalt ist passwortgeschützt. Um ihn anschauen zu können, bitte das Passwort eingeben:

Geschützt: Eingehende IDoc erzeugen (Staffeln/Konditionssätze)

Dieser Inhalt ist passwortgeschützt. Um ihn anschauen zu können, bitte das Passwort eingeben:

Geschützt: Iterate field values and field names of unknown table

Dieser Inhalt ist passwortgeschützt. Um ihn anschauen zu können, bitte das Passwort eingeben:

Einfacher REST-Service (ohne OData)

1. SE11: neue Tabelle ZREST_TAB:
MANDT:MANDT
ID:VBELN
CUSTOMER_NAME:NAME1
MOBILE:TELF1
EMAIL:AD_SMTPADR
DESCR:CHAR100
STATUS:CHAR10
ACTION_TAKEN:CHAR100
CLOSING_DATE:SYDATUM
CREATEDBY:SYUNAME
CREATEDON:SYDATUM
TIME:SYUZEIT

2. SNRO ZRESTC:NUMC10
3. Neue Klasse ZCL_WEBCO_RHANDLER und eine Überschreibung:

class ZCL_WEBCO_RHANDLER definition
  public
  inheriting from CL_REST_HTTP_HANDLER
  final
  create public .
public section.
  methods IF_REST_APPLICATION~GET_ROOT_HANDLER
    redefinition .
endclass.

if_rest_application~get_root_handler redefinition:

data lo_router type ref to cl_rest_router.
  create object lo_router.
 
  lo_router->attach(
    exporting
      iv_template      =  '/webco'    " Unified Name for Resources (-URI)
      iv_handler_class =  'ZCL_WEBCO_RESOURCEP'   " Object Type Name
  ).
  ro_root_handler = lo_router.

4. Neue Klasse ZCL_WEBCO_RESOURCEP und zwei Überschreibungen:

class ZCL_WEBCO_RESOURCEP definition
  public
  inheriting from CL_REST_RESOURCE
  final
  create public .
public section.
  methods IF_REST_RESOURCE~GET
    redefinition .
  methods IF_REST_RESOURCE~POST
    redefinition .
endclass.

if_rest_resource~get redefinition:

data: lv_string1 type vbeln,
      lv_string2 type string,
      ls_co      type zrest_tab,
      ui2_cl_json type ref to cl_trex_json_serializer.
 
  lv_string1 = mo_request->get_uri_query_parameter( iv_name = 'ID' ).
 
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input  = lv_string1
    importing
      output = lv_string1.
 
  select single * from zrest_tab into corresponding fields of ls_co where id = lv_string1.
 
  create object ui2_cl_json
    exporting
      data = ls_co.    " Data to serialize
 
  ui2_cl_json->serialize( ).
  lv_string2 = ui2_cl_json->get_data( ).
 
  mo_response->create_entity( )->set_string_data( iv_data = lv_string2 ).
 
  mo_response->set_header_field(
    exporting
      iv_name  =  'Content-Type'   " Header Name
      iv_value =  'application/json'   " Header Value
  ).

if_rest_resource~post redefinition:

  data: lv_response type string,
        lv_data type string,
		ls_com type zrest_tab,
        lt_co type standard table of zrest_tab with default key,
        ui2d_cl_json type ref to cl_trex_json_deserializer,
        ui2s_cl_json type ref to cl_trex_json_serializer,
        lo_entity type ref to if_rest_entity,
        lo_response type ref to if_rest_entity.
 
  lo_entity = mo_request->get_entity( ).
  lo_response = mo_response->create_entity( ).
 
  "read string data i.e json
  lv_data = lo_entity->get_string_data( ).
 
  create object ui2d_cl_json.
  ui2d_cl_json->deserialize( exporting json = lv_data importing abap = lt_co ).
  read table lt_co into ls_com with key mandt = 800.
 
  call function 'NUMBER_GET_NEXT'
    exporting
      nr_range_nr             = '01'
      object                  = 'ZRESTC'
      quantity                = '1'
    importing
      number                  = ls_com-id
    exceptions
      ...    .
  ...
 
  ls_com-createdby    = sy-uname.
  ls_com-createdon    = sy-datum.
  ls_com-time         = sy-uzeit.
 
  insert into zrest_tab values ls_com.
 
  create object ui2s_cl_json
    exporting
      data = lt_co.    " Data to serialize
 
  ui2s_cl_json->serialize( ).
 
  lv_response = ui2s_cl_json->get_data( ).
 
  lo_response->set_string_data( iv_data = lv_response ).
endmethod.

5. SICF neuer Service /sap/bc/rest/webco – HandlerList:ZCL_WEBCO_RHANDLER
6. (Test) SoapUI https://sapgw.sys100.sap.sd:8000/sap/bc/rest/webco (x-csrf-Token?)

Die Tabelle ZREST_TAB enthält jetzt die neue Zeilen.

ABAP Query – clean some output entries

END-OF-SELECTION (nach Liste):

field-symbols: <g00> type table,
               <wa_g00> type any,
               <k1> type any,
               <ks> type any.
data: it_g00 type char100 value '%G00[]',
      lv_kna1land type string,
      lv_knasland type string.
assign (it_g00) to <g00>.
if <g00> is assigned.
 loop at <g00> assigning <wa_g00>.
    lv_kna1land = '<wa_g00>-kna1-land1'.
    lv_knasland = '<wa_g00>-knas-land1'.
    unassign: <k1>, <ks>.
    assign: (lv_kna1land) to <k1>,
            (lv_knasland) to <ks>.
  if <k1> is assigned.
    if <ks> is assigned.
      if <k1> eq <ks>.
        delete <g00>.
      endif.
    endif.
  endif.
 endloop.
endif.
" END-OF-SELECTION

Geschützt: EWM/ABAP – Adjust quantity

Dieser Inhalt ist passwortgeschützt. Um ihn anschauen zu können, bitte das Passwort eingeben:

Change spool request name (ewm)

To change spool request name for printing forms (they are was set up in SPPFCADM transaction) we can add next enhancement into FM /SCWM/EXECUTE_PPF_WO_PDF (warehouse order):

ENHANCEMENT 1  Y_PPF_WO_PDF.    "active version
  field-symbols: <ft> type /scwm/tt_whohu_pdf.
  assign ('LT_WHOHU_PDF') to <ft>.
  if <ft> is assigned.
    zscwm_ex_prnt_pdf_wo=>set_whohu_ref( changing ct_whohu = <ft> ).
  endif.
  data: v_text1(10)
       ,v_text2(10)
       ,v_text3(10)
       ,v_text4(20).
    xs_output_params-reqnew   = 'X'.
    xs_output_params-reqfinal = 'X'.
    split xs_output_params-covtitle at ' ' into v_text1 v_text2 v_text3 v_text4.
    clear: xs_output_params-covtitle.
 
    case iv_form.
      when 'Y_ZAKAZ_WO_MULTIPLE'.
        xs_output_params-covtitle = v_text3 && ' - Заказ на комплектование - ' &&  v_text2.
      when 'Y_ZAKAZ__WO_HUIDENT'.
        xs_output_params-covtitle = v_text3 && ' - ЕО (Handling unit) - ' &&  v_text2.
      when 'Y_BIRKA_DETALI_UZLA'.
        xs_output_params-covtitle = v_text3 && ' - Бирка №1 - ' &&  v_text2.
      when 'Y_BIRKA_DETALI_UZLA_N0'.
        xs_output_params-covtitle = v_text3 && ' - Бирка №0 - ' &&  v_text2.
    endcase.
ENDENHANCEMENT.

For HU forms (FM /SCWM/EXECUTE_PPF_HU_PDF):

ENHANCEMENT 1  YEI_PPF_HU_PDF.    "active version
  FIELD-SYMBOLS: <ft> TYPE /scwm/tt_huhdr_int.
  ASSIGN ('IT_HUHDR') TO <ft>.
  IF <ft> IS ASSIGNED.
    yscwm_ex_prnt_pdf_hu=>set_huhdr_ref( CHANGING ct_huhdr = <ft> ).
  ENDIF.
ENDENHANCEMENT.

Geschützt: Convert spool list to internal table

Dieser Inhalt ist passwortgeschützt. Um ihn anschauen zu können, bitte das Passwort eingeben:

Rename file on Application server

form datei_umbenennen using lv_altpfad lv_neupfad type string.
  data: lv_eof_reached   type c,
        lv_buffer(20480),
        lv_buflen        type i.
 
  open dataset lv_altpfad for input in binary mode.
  if sy-subrc ne 0.
    raise open_input_file_failed.
  endif.
 
  open dataset lv_neupfad for output in binary mode.
  if sy-subrc ne 0.
    raise open_output_file_failed.
  endif.
 
  clear lv_eof_reached.
 
  do.
    clear lv_buffer.
 
    read dataset lv_altpfad
            into lv_buffer length lv_buflen.
 
    if sy-subrc = 4.
      lv_eof_reached = 'X'.
    elseif sy-subrc > 4.
      raise read_block_failed.
    endif.
 
    transfer lv_buffer to lv_neupfad
      length lv_buflen.
 
    if sy-subrc ne 0.
      raise write_block_failed.
    endif.
 
    if lv_eof_reached eq 'X'.
      exit.
    endif.
  enddo.
 
  close dataset lv_altpfad.
  close dataset lv_neupfad.
  if sy-subrc <> 0.
    raise close_output_file_failed.
  endif.
 
  delete dataset lv_altpfad.
endform.

FMs and BAPIs to create customer/vendor master

_sap

Customers:
SD_CUSTOMER_MAINTAIN_ALL – quite powerful, but has no RFC (should be wrapped for it)
BAPI_CUSTOMER_CREATEFROMDATA1 – much simple, but has RFC (a BAPI).
As an additional way – using IDocs (DEBMAS).

Vendors:
Class VMD_EI_API – methods Initialize and Maintenance
Functional group LC01.
As an additional way – IDocs (CREMAS).