Eingehende IDoc erzeugen (Staffeln/Konditionssätze)

function y_staffladen.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_KSCHL) TYPE  KSCHL OPTIONAL
*"     REFERENCE(IV_KAPPL) TYPE  KAPPL
*"     REFERENCE(IV_STFKZ) TYPE  STFKZ
*"     REFERENCE(EKORG) TYPE  EKORG
*"     REFERENCE(MATNR) TYPE  MATNR
*"     REFERENCE(LIFNR) TYPE  LIFNR
*"     REFERENCE(WERK) TYPE  WERKS-WERKS
*"     REFERENCE(DATAB) TYPE  DATAB
*"     REFERENCE(DATBI) TYPE  DATBI
*"----------------------------------------------------------------------
 
  constants: lcon_table_no_017   type kotabnr value '017',
             lcon_applicatio_m   type kappl value 'M',
             lcon_cond_type_zpb0 type kschl value 'ZPB0',
             lcon_scale_type_a   type stfkz value 'A',
             lcon_calc_type_c    type krech value 'C',
             lcon_valid_from     type kodatab value '19960330',
             lcon_valid_to       type kodatbi value '66660606',
             lcon_cond_usage_a   type kvewe value 'A',
             lcon_cond_count_i   type kopos value '01'.
 
  types: begin of t_varkey_a017_header,
           vkorg type vkorg,
           vtweg type vtweg,
           spart type spart,
           kunnr type kunnr_v,
           pltyp type pltyp,
           waerk type waerk,
           matnr type matnr,
         end of t_varkey_a017_header.
 
  data: ls_edidc    type edi_dc40,
        lt_edidd    type table of edi_dd40,
        ls_edidd    like line of lt_edidd,
        ls_e1komg   type e1komg,
        ls_e1konh   type e1konh,
        ls_e1konp   type e1konp,
        ls_e1konm   type e1konm,
        lv_varkey   type t_varkey_a017_header.
 
  ls_edidd-segnam = 'E1KOMG'.
  ls_edidd-psgnum = '0000'.
  ls_edidd-hlevel = '01'.
  ls_e1komg-kvewe = lcon_cond_usage_a.
  ls_e1komg-kotabnr = lcon_table_no_017.
  ls_e1komg-kappl = lcon_applicatio_m.
  ls_e1komg-kschl = lcon_cond_type_zpb0.
* varkey aus KONH:
  ls_e1komg-vakey = '0280011017A400              2155300 0'.
* ls_varkey = sy-mandt &&'M'&&'KSCHL'&&'LIFNR'&&'MATNR'&&'EKORG'&&'WERKS'&&'ESOKZ'&&'DATBI'&&'DATAB'.
  ls_edidd-sdata  = ls_e1komg.
  append ls_edidd to lt_edidd.
  clear ls_edidd.
 
  ls_edidd-segnam = 'E1KONH'.
  ls_edidd-psgnum = '0001'.
  ls_edidd-hlevel = '01'.
  ls_e1konh-datab = lcon_valid_from.
  ls_e1konh-datbi = lcon_valid_to.
  ls_edidd-sdata  = ls_e1konh.
  append ls_edidd to lt_edidd.
  clear ls_edidd.
 
  ls_edidd-segnam = 'E1KONP'.
  ls_edidd-psgnum = '0001'.
  ls_edidd-hlevel = '01'.
  ls_e1konp-kschl = lcon_cond_type_zpb0.
  ls_e1konp-stfkz = lcon_scale_type_a.
  ls_e1konp-kzbzg = 'C'.
  ls_e1konp-konms = 'PCE'.
  ls_e1konp-krech = lcon_calc_type_c.
  ls_e1konp-konwa = 'EUR'.
  ls_e1konp-kmein = 'PCE'.
  ls_e1konp-kwaeh = 'EUR'.
  ls_e1konp-zaehk_ind = lcon_cond_count_i.
  ls_edidd-sdata  = ls_e1konp.
  append ls_edidd to lt_edidd.
  clear ls_edidd.
 
  ls_edidd-segnam = 'E1KONM'.
  ls_edidd-psgnum = '0002'.
  ls_edidd-hlevel = '01'.
  ls_e1konm-kstbm = '1000'.
  ls_e1konm-kbetr = '16.30'.
  ls_edidd-sdata  = ls_e1konm.
  append ls_edidd to lt_edidd.
  clear ls_edidd.
 
  ls_edidd-segnam = 'E1KONM'.
  ls_edidd-psgnum = '0002'.
  ls_edidd-hlevel = '01'.
  ls_e1konm-kstbm = '10000'.
  ls_e1konm-kbetr = '15.50'.
  ls_edidd-sdata  = ls_e1konm.
  append ls_edidd to lt_edidd.
  clear ls_edidd.
 
  ls_edidc-mestyp = 'COND_A'.
  ls_edidc-idoctyp = 'COND_A04'.
  ls_edidc-rcvpor = ls_edidc-sndpor = 'SAPDEV'.
  ls_edidc-rcvprt = ls_edidc-sndprt = 'LS'.
  ls_edidc-sndprn = ls_edidc-rcvprn ='DEVCLNT100'.
  ls_edidc-status = '64'.
  ls_edidc-direct = '2'.
 
  call function 'IDOC_INBOUND_SINGLE'
    exporting
      pi_idoc_control_rec_40  = ls_edidc
      pi_do_commit            = 'X'
*  importing
*    pe_idoc_number
    tables
      pt_idoc_data_records_40 = lt_edidd
    exceptions
      idoc_not_saved          = 1
      others                  = 2.
 
endfunction.

Schreibe einen Kommentar



All fields are required. Your email address will not be published.