Cerca nel blog

martedì 20 dicembre 2022

ABAP:Modifica del work center quando viene creato la schedulazione del programma di manutenzione IP10

 

Modifica del work center quando viene creato la schedulazione del programma di manutenzione IP10


Abbiamo la necessita di modificare il work center delle operazioni dell'ordine che viene creato quando viene creato la schedulazione del programma di manutenzione Tcode IP10.

Nella user exit EXIT_SAPLMCI1_001, leggiamo la tabella interna I_MCIPMB, per capire il nr dell'ordine che si sta creando.

 READ TABLE i_mcipmb ASSIGNING FIELD-SYMBOL(<lfs_mcipmb>) INDEX 1.

lv_aufnr = <lfs_mcipmb>-aufnr.

 lv_aufnr2  = |{ lv_aufnr     ALPHA = OUT } |.

Valorizzo il nome del job che creeremo.

CONCATENATE 'ZJOB_UGP_WORKORDER_' lv_aufnr2 INTO v_jobname.

Valorizzo il parametro che passeremo al programma che verrà chiamato dal job.

      FREE: lt_rsparams[].

      CLEAR ls_rspar.

      ls_rspar-selname = 'P_AUFNR'.

      ls_rspar-kind = 'S'.

      ls_rspar-sign = 'I'.

      ls_rspar-option = 'EQ'.

      ls_rspar-low = lv_aufnr.

      APPEND ls_rspar TO lt_rsparams.

Richiamo un FM in una nuova sessione. Il FM deve essere creato in modo da essere richiamato dall'esterno

      CALL FUNCTION 'ZPM_JOB_CREATE'

       STARTING NEW TASK 'TASK'

        EXPORTING

          i_aufnr   = lv_aufnr

          jobname   = v_jobname

          progname  = 'ZUGP_WORKORDER'

          strtimmed = abap_true

        TABLES

          rsparams  = lt_rsparams.

Il FM ha i seguenti parametri:


Nel FM, controlliamo che non esiste già un job con lo stesso nome. Poi verifichiamo che l'ordine sia stato creato e presente in tabella AFKO, e poi creiamo il job che richiamerà il programma ZUGP_WORKORDER.

FUNCTION zpm_job_create_ugp_workorder.

  DATA: vn_jobcount   LIKE tbtcjob-jobcount,

        lv_sdlstrtdt  TYPE tbtcjob-sdlstrtdt,

        lv_sdlstrttm  TYPE tbtcjob-sdlstrttm,

        lv_timestamp  TYPE string,

        ls_msg        TYPE bal_s_msg,

        lv_extnumber  TYPE balnrext,

        lv_errore     TYPE boolean,

        lv_log_handle TYPE balloghndl,

        lv_finished   LIKE tbtcv-fin.


*I check if the job already exists, in this case I exit the FM

  SELECT SINGLE @abap_true

           FROM tbtco

           INTO @DATA(gv_job_exists)

          WHERE jobname = @jobname.


  IF gv_job_exists = abap_true.

    EXIT.

  ENDIF.


  DO 3 TIMES.

    SELECT SINGLE @abap_true

          FROM afko

          INTO @DATA(gv_orderexists)

         WHERE aufnr = @i_aufnr.


    IF gv_orderexists = abap_false.

      WAIT UP TO 3 SECONDS.

    ELSE.

      EXIT.

    ENDIF.

  ENDDO.


  IF gv_orderexists = abap_false.

    EXIT.

  ENDIF.

  IF user IS INITIAL.

    user = sy-uname.

  ENDIF.


    CALL FUNCTION 'JOB_OPEN'

      EXPORTING

        jobname          = jobname

        jobclass         = 'A' "jobclass

      IMPORTING

        jobcount         = vn_jobcount

      EXCEPTIONS

        cant_create_job  = 1

        invalid_job_data = 2

        jobname_missing  = 3

        OTHERS           = 4.

    IF sy-subrc = 0.

      SUBMIT (progname)

      USER user

      VIA JOB jobname NUMBER vn_jobcount

      WITH SELECTION-TABLE rsparams

      AND RETURN.


      CALL FUNCTION 'JOB_CLOSE'

        EXPORTING

          jobcount             = vn_jobcount

          jobname              = jobname

          strtimmed            = abap_true " start immediately

        EXCEPTIONS

          cant_start_immediate = 1

          invalid_startdate    = 2

          jobname_missing      = 3

          job_close_failed     = 4

          job_nosteps          = 5

          job_notex            = 6

          lock_failed          = 7

          invalid_target       = 8

          OTHERS               = 9.

  ENDIF.

ENDFUNCTION.


Nel  programma ZUGP_WORKORDER:

Leggiamo i dati dell’ordine richiamando il FM BAPI_ALM_ORDER_GET_DETAIL

Se sono presenti le operazioni, aggiorniamo il work center delle operazioni con il FM BAPI_ALM_ORDER_MAINTAIN

REPORT zpm_ugp_workorder.

START-OF-SELECTION.

    PERFORM get_order_get_detail   USING lv_aufnr

                                CHANGING lv_modify_ok.

    PERFORM change_operation  USING lv_aufnr lv_modify_ok.

END-OF-SELECTION.


FORM get_order_get_detail  USING  pv_aufnr CHANGING pv_modify_ok.

  DATA: lv_errore      TYPE boolean,

        lv_arbpl       TYPE arbpl,

        lwa_operations TYPE bapi_alm_order_operation_e,

        lt_return      TYPE STANDARD TABLE OF bapiret2,

        lt_olist       TYPE STANDARD TABLE OF

                            bapi_alm_order_objectlist,

        lt_rules       TYPE STANDARD TABLE OF

                            bapi_alm_order_srule_e.


  CLEAR: pv_modify_ok, lv_errore, lv_arbpl, lwa_operations,

         gv_header, gv_srvdata, gv_reforder_item.


  FREE: lt_return[], lt_rules[], lt_olist[].

  CALL FUNCTION 'BAPI_ALM_ORDER_GET_DETAIL'

    EXPORTING

      number           = pv_aufnr

    IMPORTING

      es_header        = gv_header

      es_srvdata       = gv_srvdata

      es_reforder_item = gv_reforder_item

    TABLES

      et_operations    = gt_operations

      et_srules        = lt_rules

      et_olist         = lt_olist

      return           = lt_return.


  IF   gt_operations[] IS NOT INITIAL.

       lv_arbpl = '999999'.

      lwa_operations-work_cntr = lv_arbpl.

      MODIFY gt_operations  FROM lwa_operations TRANSPORTING work_cntr

       WHERE work_cntr NE lv_arbpl.

  ENDIF.

ENDFORM.


FORM change_operation  USING    pv_aufnr pv_modify_ok.


  DATA: lv_aufnr        TYPE aufnr,

        lt_methods      TYPE bapi_alm_order_method_t,

        lt_return       TYPE STANDARD TABLE OF bapiret2,

        lt_operation    TYPE bapi_alm_order_operation_t,

        lt_operation_up TYPE bapi_alm_order_operation_ut,

        lt_header       TYPE bapi_alm_order_header_t,

        lwa_header      TYPE bapi_alm_order_headers_i,

        lt_header_up    TYPE  bapi_alm_order_headers_i_ut,

        lwa_header_up   TYPE  bapi_alm_order_headers_up,

        lv_errore       TYPE boolean.


  CHECK pv_modify_ok = abap_true.

  lv_aufnr = pv_aufnr.

  FREE: lt_methods[], lt_operation_up[], lt_operation[],

        lt_header[], lt_header_up[].


  CLEAR: lwa_header, lv_errore.

  lwa_header-orderid = gv_header-orderid.

  lwa_header-order_type = gv_header-order_type.

  APPEND lwa_header TO lt_header.


  CLEAR: lwa_header_up.

  lwa_header_up-orderid = gv_header-orderid.

  APPEND lwa_header_up TO lt_header_up.


  lv_aufnr  = |{ lv_aufnr ALPHA = IN  } |.


  PERFORM fill_tables     USING lv_aufnr

                      CHANGING lt_methods[]

                               lt_operation[]

                               lt_operation_up[].


  CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

    TABLES

      it_methods      = lt_methods

      it_header       = lt_header

      it_header_up    = lt_header_up

      it_operation    = lt_operation

      it_operation_up = lt_operation_up

      return          = lt_return.


  IF lv_errore = abap_true.

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  ELSE.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

        wait = 'X'.

  ENDIF.

ENDFORM.


FORM fill_tables     USING lv_aufnr

                  CHANGING pt_methods       TYPE bapi_alm_order_method_t

                           pt_operation     TYPE bapi_alm_order_operation_t

                           pt_operation_up  TYPE bapi_alm_order_operation_ut.


  DATA: lwa_methods      TYPE bapi_alm_order_method,

        lwa_operation    TYPE bapi_alm_order_operation,

        lwa_operation_up TYPE bapi_alm_order_operation_up,

        lv_nr_item       TYPE ifrefnum,

        lv_nr_object(4)  TYPE n,

        lv_nr_objectc(4) TYPE c,

        lv_objectkey     TYPE objidext.


  CLEAR: lv_nr_item, lv_objectkey, lv_nr_object.

  LOOP AT gt_operations ASSIGNING FIELD-SYMBOL(<lfs_oper>).

    lv_nr_item = lv_nr_item + 1.

    lv_nr_object = lv_nr_object + 10.

    lv_nr_objectc = lv_nr_object.

    lv_objectkey = |{ lv_aufnr }{ lv_nr_object }|.


*******Fill structure methods

    CLEAR: lwa_methods.

    lwa_methods-refnumber   = lv_nr_item.

    lwa_methods-objecttype  = gc_obj_operation.

    lwa_methods-method      = gc_meth_change.

    lwa_methods-objectkey   = lv_objectkey.

    APPEND lwa_methods TO pt_methods.


*******Fill structure operation

    CLEAR: lwa_operation.

    lwa_operation-activity   = lv_nr_objectc.

    lwa_operation-work_cntr  = <lfs_oper>-work_cntr.

    APPEND lwa_operation TO pt_operation.


*******Fill structure operation_up

    CLEAR: lwa_operation_up.

    lwa_operation_up-activity   = abap_true.

    lwa_operation_up-work_cntr  = abap_true.

    APPEND lwa_operation_up TO pt_operation_up.

  ENDLOOP.


*******Fill structure methods FINAL

  CLEAR: lwa_methods.

  lwa_methods-refnumber = lv_nr_item.

  lwa_methods-method    = gc_meth_save.

  APPEND lwa_methods TO pt_methods.

ENDFORM.




martedì 11 ottobre 2022

Creazione di un IDOC custom che richiama un WS di tipo REST ed invia un file Json

 

Creazione di un IDOC custom che richiama un WS di tipo REST ed invia un file Json


Dopo aver creato un nostro Idoc ( Vedere post: ABAP - IDoc Definizione), passiamo alle varie configurazioni:

STEP NR. 1: Configuriamo il sistema esterno

Richiamiamo la transazione OMKYe definiamo un nome per il sistema esterno




STEP NR. 2: Definiamo la porta

Richiamiamo la transazione WE21, e definiamo la porta ZTEST e il FM ZFM_TEST_IDOC_TO_WS_REST associato per gestire l’Idoc

STEP NR. 3: Definiamo la porta

Richiamiamo la transazione WE20, e definiamo gli accordi partner e associato la porta definita in precedenza

STEP NR. 3: Creiamo Il FM ZFM_TEST_IDOC_TO_WS_REST (di tipo RFC) che richiama il FM che richiama a sua volta IL WS di tipo REST 

FUNCTION ZFM_TEST_IDOC_TO_WS_REST .

  
TABLESedidcedi_ds.

  
DATABEGIN OF i_edidd OCCURS 0.
      
INCLUDE STRUCTURE edidd.
  
DATAEND OF i_edidd.

  
DATAerror(1).
  
DATA lv_tech_error"X=set 02 status

  
LOOP AT i_edidc.

    
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_PROCESS'
      
EXPORTING
*       DB_READ_OPTION           = DB_READ
        document_number          
i_edidc-docnum
*       ENQUEUE_OPTION           = SYNCHRONOUS
      
IMPORTING
        idoc_control             
edidc
      
EXCEPTIONS
        document_foreign_lock    
1
        document_not_exist       
2
        document_number_invalid  
3
        document_is_already_open 
4
        
OTHERS                   5.
    
IF sy-subrc <> 0.
      
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    
ENDIF.

    
CLEAR i_edidd.
    
REFRESH i_edidd.

    
CALL FUNCTION 'EDI_SEGMENTS_GET_ALL'
      
EXPORTING
        document_number         
i_edidc-docnum
      
TABLES
        idoc_containers         
i_edidd
      
EXCEPTIONS
        document_number_invalid 
1
        end_of_document         
2
        
OTHERS                  3.
    
IF sy-subrc <> 0.
      
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    
ENDIF.

*ho trovato la function da lanciare
      
DATA lt_ret TYPE bapiret2_tab WITH HEADER LINE.

      
CALL FUNCTION 'ZFM_TEST_WS_DA_IDOC_WMTOID01'
        
EXPORTING
          i_docnum     
i_edidc-docnum
        
IMPORTING
          ot_ret       
lt_ret[]
          o_tech_error 
lv_tech_error.

      
READ TABLE lt_ret WITH KEY type 'E' TRANSPORTING NO FIELDS.
      
IF sy-subrc 0.
        error 
'Y'.
        
CLEAR edi_ds.
      
ENDIF.

IF error 'Y'.

      
IF edi_ds IS NOT INITIAL.
        edi_ds
-docnum i_edidc-docnum.
        edi_ds
-tabnam 'EDI_DS'.
        edi_ds
-logdat sy-datum.
        edi_ds
-logtim sy-uzeit.
        edi_ds
-repid 'ZFM_TEST_IDOC_TO_WS_REST'.
        
IF lv_tech_error 'X'.
          edi_ds
-status '02'"Error passing data to port
        
ELSE.
          edi_ds
-status '29'" Error in ALE service
        
ENDIF.
        edi_ds
-stamqu 'SAP'.

        
CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
          
EXPORTING
            document_number         
i_edidc-docnum
            idoc_status             
edi_ds
          
EXCEPTIONS
            document_number_invalid 
1
            other_fields_invalid    
2
            status_invalid          
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.
      
ENDIF.

      
LOOP AT   lt_ret .
        
CLEAR edi_ds .
        edi_ds
-docnum i_edidc-docnum.
        edi_ds
-tabnam 'EDI_DS'.
        edi_ds
-logdat sy-datum.
        edi_ds
-logtim sy-uzeit.
        edi_ds
-repid 'ZFM_TEST_IDOC_TO_WS_REST'.
        
IF lv_tech_error 'X'.
          edi_ds
-status '02'"Error passing data to port
        
ELSE.
          edi_ds
-status '29'" Error in ALE service
        
ENDIF.
        edi_ds
-stamqu 'SAP'.
        edi_ds
-stamid lt_ret-id.
        edi_ds
-stamno lt_ret-number.
        edi_ds
-stapa1 lt_ret-message_v1.
        edi_ds
-stapa2 lt_ret-message_v2.
        edi_ds
-stapa3 lt_ret-message_v3.
        edi_ds
-stapa4 lt_ret-message_v4.

        
CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
          
EXPORTING
            document_number         
i_edidc-docnum
            idoc_status             
edi_ds
          
EXCEPTIONS
            document_number_invalid 
1
            other_fields_invalid    
2
            status_invalid          
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.
      
ENDLOOP.
    
ELSE.
      
CLEAR edi_ds .
      edi_ds
-docnum i_edidc-docnum.
      edi_ds
-tabnam 'EDI_DS'.
      edi_ds
-logdat sy-datum.
      edi_ds
-logtim sy-uzeit.
      edi_ds
-repid 'ZFM_TEST_IDOC_TO_WS_REST'.
      edi_ds
-status '12'.
      edi_ds
-stamqu 'SAP'.

      
CALL FUNCTION 'EDI_DOCUMENT_STATUS_SET'
        
EXPORTING
          document_number         
i_edidc-docnum
          idoc_status             
edi_ds
        
EXCEPTIONS
          document_number_invalid 
1
          other_fields_invalid    
2
          status_invalid          
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.
    
ENDIF.

    
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_PROCESS'
      
EXPORTING
        document_number     
i_edidc-docnum
*       BACKGROUND          = NO_BACKGROUND
*       NO_DEQUEUE          = ' '
*      IMPORTING
*       IDOC_CONTROL        =
      
EXCEPTIONS
        document_not_open   
1
        failure_in_db_write 
2
        parameter_error     
3
        status_set_missing  
4
        
OTHERS              5.
    
IF sy-subrc <> 0.
      
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    
ENDIF.

  
ENDLOOP.
ENDFUNCTION.

STEP NR. 4: CREAIMO IL SECONDO FM ZFM_TEST_WS_DA_IDOC_WMTOID01 che richiama IL WS di tipo REST

FUNCTION ZFM_TEST_WS_DA_IDOC_WMTOID01.

*dati idoc
  
DATA ls_idoc_control  LIKE  edidc .
  
DATA lt_edidd TYPE edidd OCCURS WITH HEADER LINE.
  
DATAwa           LIKE LINE OF lt_edidd.

  
DATAwa_e1ltorh     TYPE e1ltorh,
        wa_e1ltori     
TYPE e1ltori.

  
DATAhttp_client          TYPE REF TO if_http_client,
        http_url             
TYPE string,
        p_content            
TYPE string,
        lv_json              
TYPE string,
        ls_to_create         
TYPE z_test_s_to_create,
        ls_imp_ordini_righe  
TYPE zwm_test_s_to_create_item,
        ls_imp_ordini_header 
TYPE zwm_test_s_to_create_header,
        lv_tanum             
TYPE tanum,
        lsret                
LIKE LINE OF ot_ret,
        lv_text
(255),
        oref_exception       
TYPE REF TO cx_root,
        lv_status            
TYPE i.


  
WAIT UP TO SECONDS
  
SET LANGUAGE 'I'.
  
SET LOCALE LANGUAGE 'I'.

  
CALL FUNCTION 'IDOC_READ_COMPLETELY'
    
EXPORTING
      document_number         
i_docnum
    
IMPORTING
      idoc_control            
ls_idoc_control
    
TABLES
      int_edidd               
lt_edidd
    
EXCEPTIONS
      document_not_exist      
1
      document_number_invalid 
2
      
OTHERS                  3.
  
IF lt_edidd[] IS INITIAL.
    lsret
-type 'E'.
    lsret
-id 'ZCL_MSG'.
    lsret
-number '007'.
    lsret
-message_v1 i_docnum.
    lsret
-message_v2 ''.
    lsret
-message_v3 ''.
    lsret
-message_v4 ''.
    
APPEND lsret TO ot_ret.

    
EXIT.
  
ENDIF.

  
SORT lt_edidd BY docnum segnum.

  
CLEAR ls_to_create.

  
READ TABLE lt_edidd INTO wa WITH KEY segnam 'E1LTORH'.
  
MOVE wa-sdata TO wa_e1ltorh.
  lv_tanum 
wa_e1ltorh-tanum.

    
LOOP AT lt_edidd INTO wa.
      
CASE wa-segnam.
        
WHEN 'E1LTORH'.
* Header segment
          
MOVE wa-sdata TO wa_e1ltorh.
* Map header seg field to MOD JSON structure
          
CLEAR ls_imp_ordini_header.
          
MOVE wa_e1ltorh-lgnum TO ls_imp_ordini_header-ord_attr1.
          
MOVE wa_e1ltorh-tanum TO ls_imp_ordini_header-ord_ordine.
          lv_tanum 
wa_e1ltorh-tanum.

          
APPEND ls_imp_ordini_header TO ls_to_create-imp_ordini.

        
WHEN 'E1LTORI'.
* Item segment
          
MOVE wa-sdata TO wa_e1ltori.
* Map Item seg field to MOD JSON structure
          
CLEAR ls_imp_ordini_righe.
          
MOVE wa_e1ltori-tapos TO ls_imp_ordini_righe-rig_hostinf.
          
MOVE wa_e1ltori-matnr TO ls_imp_ordini_righe-rig_articolo.
          
MOVE wa_e1ltori-charg TO ls_imp_ordini_righe-rig_sub1.
          
APPEND ls_imp_ordini_righe TO ls_to_create-imp_ordini_righe.
      
ENDCASE.
    
ENDLOOP.

* chiamata webservice
    
TRY.
* ABAP to JSON Serializer
        lv_json 
/ui2/cl_json=>serializedata ls_to_create ).

        
CALL METHOD cl_http_client=>create_by_destination
          
EXPORTING
            destination              
'Z_TEST_TO_CREATE'
          
IMPORTING
            
client                   http_client
          
EXCEPTIONS
            argument_not_found       
1
            destination_not_found    
2
            destination_no_authority 
3
            plugin_not_active        
4
            internal_error           
5
            
OTHERS                   6.

        
IF sy-subrc <> 0.
* Gestione Errori
          lsret
-type 'E'.
          lsret
-id 'ZCL_MSG'.
          
CASE sy-subrc.
            
WHEN '1'lsret-number '018'.
            
WHEN '2'lsret-number '019'.
            
WHEN '3'lsret-number '020'.
            
WHEN OTHERSlsret-number '009'.
          
ENDCASE.
          
APPEND lsret TO ot_ret.
* Gestione  o_tech_error
          o_tech_error 
'X'.

          
EXIT.
        
ENDIF.

        
CALL METHOD http_client->request->set_method
          
EXPORTING
            
method 'POST'.

        http_client
->request->set_content_type(
         
EXPORTING
         content_type 
if_rest_media_type=>gc_appl_json ).

        
CALL METHOD http_client->request->set_cdata
          
EXPORTING
            
data lv_json.

        
CALL METHOD http_client->send
          
EXCEPTIONS
            http_communication_failure 
1
            http_invalid_state         
2
            http_processing_failed     
3
            http_invalid_timeout       
4.

        
IF sy-subrc <> 0.
* Gestione Errori
          lsret
-type 'E'.
          lsret
-id 'ZCL_MSG'.
          lsret
-number '008'.
          
CASE sy-subrc.
            
WHEN '1'lsret-number '025'.
            
WHEN '2'lsret-number '026'.
            
WHEN '3'lsret-number '027'.
            
WHEN '4'lsret-number '028'.
            
WHEN OTHERSlsret-number '010'.
          
ENDCASE.
          
APPEND lsret TO ot_ret.
* Gestione  o_tech_error
          o_tech_error 
'X'.
          
EXIT.
        
ENDIF.

        
CALL METHOD http_client->receive
          
EXCEPTIONS
            http_communication_failure 
1
            http_invalid_state         
2
            http_processing_failed     
3
            
OTHERS                     4.

        
IF sy-subrc <> 0.
* Gestione Errori
          lsret
-type 'E'.
          lsret
-id 'ZCL_MSG'.
          
CASE sy-subrc.
            
WHEN '1'lsret-number '021'.
            
WHEN '2'lsret-number '022'.
            
WHEN '3'lsret-number '023'.
            
WHEN OTHERSlsret-number '010'.
          
ENDCASE.
          
APPEND lsret TO ot_ret.
* Gestione  o_tech_error
          o_tech_error 
'X'.
          
EXIT.
        
ENDIF.

        p_content 
http_client->response->get_cdata( ).

        
CALL METHOD http_client->response->get_status
          
IMPORTING
            
code lv_status.

        
IF lv_status NE '200'.
          
EXIT.
        
ENDIF.

        
CALL METHOD http_client->close
          
EXCEPTIONS
            http_invalid_state 
1
            
OTHERS             2.
        
IF sy-subrc <> 0.
* Gestione Errori
          lsret
-type 'E'.
          lsret
-id 'ZCL_MSG'.
          
CASE sy-subrc.
            
WHEN '1'lsret-number '022'.
            
WHEN OTHERSlsret-number '010'.
          
ENDCASE.
          
APPEND lsret TO ot_ret.
* Gestione  o_tech_error
          o_tech_error 
'X'.

          
EXIT.
        
ENDIF.

      
CATCH cx_root INTO oref_exception.
* Gestione Errori
        lv_text 
oref_exception->get_text( ).
        lsret
-type 'E'.
        lsret
-id 'ZCL_MSG'.
        lsret
-number '016'.
        lsret
-message_v1 lv_text+000(50).
        lsret
-message_v2 lv_text+050(50).
        lsret
-message_v3 lv_text+100(50).
        lsret
-message_v4 lv_text+150(50).
        
APPEND lsret TO ot_ret.
* Gestione  o_tech_error
        o_tech_error 
'X'.

        
EXIT.
    
ENDTRY.

ENDFUNCTION.

STEP NR. 5: Creare la destinazione dove passare il file json Z_TEST_TO_CREATE

Transazione SM59: In collegamenti http a serve est. Creare il collegamento