ABAP Code Modification for Command Tickets

Hi Experts
Modification to processing of Command Orders & Tickets
We require a modification to the processing being performed on sales data originating from the Command Concrete system and potentially from other systems yet to come online (e.g. Reddies Cement plant).
The Sap process involved is
ZINT_INBOUND_POLLING and within that,
ZINT_CSTPORD_ROUTINES.
The problem
Currently there is an assumption that every sales order (and its deliveries) will include a product which is made to order, i.e. for which a production order will be required.
In ZINT_CSTPORD_ROUTINES, a check is made to identify the production order linked to the sales order. If there is no such production order (usually because of the customeru2019s credit status) then processing of the ticket is terminated.
This assumption would fall down if an order was to be raised (in Command) on which there is no concrete material. For example, if we sold a bag of pigment or a screed to a customer. In this case the item would be sold from stock and there would be no need for a production order
The solution
In the routine which checks for the existence of a production order, modify the code as follows:
Inspect each item on the sales order
If (and only if) there is at least one item with a category of u201CZTACu201D then check for a production order, otherwise process the order in the usual manner.
The following Coding of programs are below.
Report:      ZINT_INBOUND_POLLING
Description: REDDIES Interfaces: Polling Job for Inbound Interfaces
This report is a general file polling and distribution job for
inbound interfaces. Interfaces are identified by their assigned ID
and type values (refer to table ZINT_ADMIN). The polling job can be
run only for a single interface. This restriction has been implemented
for performance reasons. Dependent interfaces should be set up as
separate, dependent jobs in SM37.
For an interface to be triggered by this report, it must have:
1. Administrative parameters entered in table ZINT_ADMIN.
2. Other parameters (eg. organisational data such as plant or store)
   entered in table ZINT_PARAM.
3. An interface-specific function module created in accordance with
   the inbound interface template (ZINT_INBOUND_INTERFACE).
4. An interface-specific directory structure. This structure must
   be reflected in the directory parameters of table ZINT_ADMIN.
   Note that the directory names supplied in ZINT_ADMIN must exactly
   match those used for the actual directories.
This job is designed to run as a periodic background job, but can
also be run on-line when required.
On each execution, the program performs the following tasks:
1. Validate all selection parameters.
2. Read interface administration and other parameters.
3. Check the inbound directory to see if there are any new files.
4. If there is a new file.
4.1 Read the data and update the interface log.
4.2 Archive the data and update the interface log.
4.3 Call the interface function module, sending data and parameters.
4.4 Log any messages returned from the function module.
5. Exit.
Please document all changes to this job carefully and clearly. Major
additions to functionality should be put in new, parameterised form
routines wherever possible to sustain maintainablility of the code.
Change History:
Date        User  Request     Description
07/02/2006  EDWG  WG1K902600  Original program.
20.07.2007  ROBS              Changes to handle error messages better.
report zint_inbound_polling line-size  170
                            line-count 58(2)
                            message-id zz
                            no standard page heading.
Global Data Declarations
include zint_interface_data.
data: begin of tbl_messages occurs 0,
        line(132) type c,
      end of tbl_messages.
--Field Symbols--
field-symbols: <function>.
--Global Variables--
Selection Screen
--Interface Mode--
RJS Start >>>
selection-screen begin of block b1 with frame title t_mode.
parameters: p_upl radiobutton group p1.
selection-screen skip 1.
select-options: s_intid for zint_intid-zint_id
                  matchcode object zint_intid,
                s_intty for zint_intty-zint_ty
                  matchcode object zint_intty.
selection-screen uline.
parameters:  p_pro radiobutton group p1.
selection-screen skip 1.
RJS End <<<
Interface ID
parameters: p_intid like zint_intid-zint_id
                            matchcode object zint_intid.
Interface type
parameters: p_intty like zint_intty-zint_ty
                            matchcode object zint_intty
                            default 'I'.
IDOC group or set
parameters: p_intis type zint_is.
select-options: s_datum for zint_data-created_on.
selection-screen skip 1.
parameters: p_dlgrp as checkbox default c_false.
data: p_alone(1) type c value 'X'.
selection-screen skip 1.
Interface parameter set and sequence number.
parameters: p_intsi like zint_param-zint_si,
            p_intsq type zint_sq default '001' no-display.
selection-screen uline.
parameters: p_apsrv radiobutton group r1,
            p_pc    radiobutton group r1.
selection-screen skip 1.
parameters: p_nowar as checkbox default c_true.
selection-screen end   of block b1.
Event Processing
--IDOC Set Values--
at selection-screen on value-request for p_intis.
Display a selectable list of parameter sets
  perform select_idoc_set using    p_intid
                                   p_intty
                          changing p_intis
                                   v_rtcod.
  if v_rtcod ne c_noerr.
   Problem displaying parameter lists
    message i000 with 'Unable to display IDOC set values.'
                      'Please enter an interface ID and type.'.
  endif.
--Parameter Set Values-----
at selection-screen on value-request for p_intsi.
Display a selectable list of parameter sets
  perform select_parameter_set using    p_intid
                                        p_intty
                               changing p_intsi
                                        v_rtcod.
  if v_rtcod ne c_noerr.
   Problem displaying parameter lists
    message i000 with 'Unable to display parameter list values.'
                      'Please enter an interface ID and type.'.
  endif.
--Check Interface Admin.---
at selection-screen on: p_intty, p_intid.
  perform validate_interface_admin using    p_intid
                                            p_intty
                                   changing v_rtcod.
  if v_rtcod ne c_noerr.
  No administration parameters exist for interface
    message e001 with p_intid p_intty.
  endif.
--Validate Parameter Set---
at selection-screen on p_intsi.
  perform validate_interface_param using    p_intid
                                            p_intty
                                            p_intsi
                                   changing v_rtcod.
  if v_rtcod ne c_noerr.
  Parameter set does not exist for interface
    message e002 with p_intsi p_intid p_intty.
  endif.
Initialisation
initialization.
  perform set_screen_texts.
Start of Selection
start-of-selection.
RJS Start >>>
  refresh: tbl_totals, tbl_messages.
UPLOAD INBOUND DATA ---------------------
  if p_upl = 'X'.
    perform upload_data.
PROCESS NEW or ERRORS -------------------
  else.   " p_pro = 'X'.
    perform process_data.
  endif.
RJS End <<<
End of Selection
end-of-selection.
Write the log file to the specified directory
  read table t_ibfil index 1.
  perform write_log_file tables   t_ldata
                         using    s_admin-zint_lg
                                  t_ibfil-filename
                                  p_apsrv
                         changing v_rtcod.
  if v_rtcod ne c_noerr.
  Error writing to log file
    message i000 with 'Could not write to log file for interface'
                      s_admin-zint_id '/' s_admin-zint_ty.
  endif.
RJS Start >>>
Write out Messages and totals
  if p_pro = 'X'.  " Processing Data
    describe table tbl_messages lines sy-tfill.
    if sy-tfill = 0.
      write:/ 'Processing Complete. Use ZSTA to analyse'.
    else.
      loop at tbl_messages.
        write:/ tbl_messages-line.
      endloop.
    endif.
  else.  " Uploading Data
    format color col_total.
    uline.
      write:/ 'Upload Details:', 132 space.
    uline.
    format color off.
    describe table tbl_totals lines sy-tfill.
    if sy-tfill = 0.
      write:/ '0 Records Processed'.
    endif.
    loop at tbl_totals.
      write:/ 'Interface ID:', tbl_totals-zint_id,
              '     Type:', tbl_totals-zint_ty,
              '     Command Date:', tbl_totals-created_on,
              '     Records Processed:', tbl_totals-count.
    endloop.
    uline.
    message s999(b1) with 'Data Upload Completed'
                          '- Please see full Results uing trans ZSTA'.
  endif.
RJS End <<<
Form Routines
  include zint_interface_routines.
*&      Form  upload_data
      text
form upload_data.
  data: lt_admin type standard table of zint_admin with header line.
  data: l_message(80) type c.
  select * from zint_admin into table lt_admin
    where zint_id in s_intid
    and   zint_ty in s_intty.
  loop at lt_admin.
    refresh t_idata.
    refresh t_ibfil.
Progress Message
    concatenate 'Reading Inbound data files in'
                lt_admin-zint_ib
      into l_message separated by space.
    call function 'SAPGUI_PROGRESS_INDICATOR'
      exporting
      PERCENTAGE       = 0
        text             = l_message.
Check for a new inbound file and read its data.
    perform read_inbound_data tables   t_idata
                                       t_ibfil
                              using    lt_admin-zint_ib
                                       p_apsrv
                              changing v_rtcod.
    if v_rtcod         ne c_noerr and
       v_rtcod         ne 7 and               " RJS- no files found
       lt_admin-zint_ib ne space.
  Write an error to the log
      perform write_log_entry
        tables t_ldata
        using  'E'
               'ZINT_INBOUND_POLLING'
               'READ_INBOUND_DATA'
               'Problem reading inbound interface file.'
               p_nowar space.
      exit.
    endif.
Exit if there is no data.
    describe table t_idata lines v_fldsz.
    check v_fldsz gt 0.
Write inbound data to a database table, for later access
    perform write_data tables t_idata
                       using lt_admin-zint_id
                             lt_admin-zint_ty
                             lt_admin-zint_fm
                             lt_admin-zint_ib.
Move the inbound file to the archive directory
    perform archive_inbound_data tables   t_ibfil
                                 using    p_apsrv
                                          lt_admin-zint_ar
                                          lt_admin-zint_ib
                                 changing v_rtcod.
    if v_rtcod ne c_noerr.
  Write an error to the log if unable to move file
      perform write_log_entry
        tables t_ldata
        using  'E'
               'ZINT_INBOUND_POLLING'
               'ARCHIVE_INBOUND_DATA'
               'Problem archiving inbound interface file.'
               p_nowar space.
    endif.
  endloop.
endform.                    "upload_data
*&      Form  process_data
      text
form process_data.
  data: lt_idata type standard table of x_idata with header line.
  data: s_idata type x_idata,
        l_last_status(3) type c.
  data: l_message(80) type c,
        l_status(3) type c,
        l_lines(5) type c,
        l_date(10) type c.
Validate input parameters
  if p_intid = space
  or p_intty = space
  or p_intsi = space.
    message e999(b1) with 'Mandatory fields must be filled'.
  endif.
Read the interface administration parameters
  perform get_admin_parameters using    p_intid
                                        p_intty
                               changing s_admin
                                        v_rtcod.
  if v_rtcod ne c_noerr.
  Write an error to the log
    perform write_log_entry
      tables t_ldata
      using  'E'
             'ZINT_INBOUND_POLLING'
             'GET_ADMIN_PARAMETERS'
             'No admin. parameters for interface. Check ZINT_ADMIN'
             p_nowar space.
  endif.
Read the other interface parameters (if required)
  if p_intsi ne space.
    perform get_other_parameters tables   t_param
                                 using    p_intid
                                          p_intty
                                          p_intsi
                                 changing v_rtcod.
    if v_rtcod ne c_noerr.
    Write an error to the log
      perform write_log_entry
        tables t_ldata
        using  'E'
               'ZINT_INBOUND_POLLING'
               'GET_OTHER_PARAMETERS'
               'No org. parameters for interface. Check ZINT_ADMIN'
               p_nowar space.
    endif.
  endif.
Read any Error records for reprocessing - if none, read New data
  perform read_data tables t_zint_data
                    changing v_rtcod.
  clear l_status.
  loop at t_zint_data.
Create subset of all records, per Command Date
    at new created_on.
      refresh t_idata.
      clear l_lines.
    endat.
    at new key_val.
      add 1 to l_lines.
    endat.
    append t_zint_data-raw_data to t_idata.
Process one date at a time
    at end of created_on.
Progress Message:
      write t_zint_data-created_on to l_date dd/mm/yyyy.
      concatenate 'Processing' l_lines 'records for'
                  p_intid '/' p_intty '/' p_intsi 'Created:'
                  l_date
        into l_message separated by space.
      call function 'SAPGUI_PROGRESS_INDICATOR'
        exporting
          text = l_message.
Process the incoming data
      assign s_admin-zint_fm to <function>.
      call function <function>
        exporting
          i_zint_id             = p_intid
          i_zint_ty             = p_intty
          i_zint_si             = p_intsi
          i_zint_is             = p_intis
          i_zint_dl             = p_dlgrp
          i_zint_as             = p_apsrv
          i_zint_al             = p_alone
          i_zint_nw             = p_nowar
          i_zint_sq             = p_intsq
        tables
          t_zint_mslog          = t_ldata
          t_zint_idata          = t_idata
          t_zint_param          = t_param
        changing
          c_zint_rc             = v_rtcod
        exceptions
          no_such_interface     = 1
          invalid_parameter_set = 2
          data_table_empty      = 3
          invalid_idoc_group    = 4.
      case sy-subrc.
--No Such Interface--
        when 1.
          perform write_log_entry
            tables t_ldata
            using  'E' 'ZINT_INBOUND_POLLING' <function>
                   'Interface does not exist in ZINT_ADMIN.'
                   p_nowar space.
--Invalid Parameter Set----
        when 2.
          perform write_log_entry
            tables t_ldata
            using  'E' 'ZINT_INBOUND_POLLING' <function>
                   'Invalid parameter set for interface. Check ZINT_PARAM'
                   p_nowar space.
--Data Table Empty--
        when 3.
          perform write_log_entry
            tables t_ldata
            using  'E' 'ZINT_INBOUND_POLLING' <function>
                   'No inbound data. Check directory as per ZINT_ADMIN'
                   p_nowar space.
--Invalid IDOC group--
        when 4.
          perform write_log_entry
            tables t_ldata
            using 'E' 'ZINT_INBOUND_POLLING' <function>
                  'Invalid IDOC group. Check ZINT_ADMIN.'
                  p_nowar space.
--Others--
        when others.
      endcase.
Now store messages not related to a specific key
      loop at t_ldata into s_ldata where key_val = space.
        move s_ldata-messg to tbl_messages-line.
        append tbl_messages.
      endloop.
      refresh t_ldata.
If data for last date had errors, then stop processing further dates
      clear l_last_status.
      select status from zint_data into l_last_status
        where zint_id = p_intid
        and   zint_ty = p_intty
        and   key_val = t_zint_data-key_val.
      endselect.
      if l_last_status = 'ERR'.
        concatenate 'Processing Halted - Errors for Date' l_date
          into l_message separated by space.
        message s999(b1) with 'ZINT_INBOUND_POLLING' <function>
                 l_message.
        exit.
      endif.
    endat.
  endloop.
endform.                    "process_data
*&      Form  set_screen_texts
      Assign values to the selection screen titles.
form set_screen_texts .
  t_mode  = 'Run Mode'.                                     " RJS
endform.                    " set_screen_texts
RJS Start >>>
*&      Form  write_data
      Save the Inbound data to table ZINT_DATA, for later processing
     -->PT_IDATA   text
     -->PV_ID      text
     -->PV_TY      text
     -->PV_FM
     -->PV_IB
form write_data tables pt_idata structure zint_idata
                using  pv_id
                       pv_ty
                       pv_fm
                       pv_ib.
  data: l_key_val    like zint_data-key_val,
        l_seq        like zint_data-sequence,
        l_created_on like zint_data-created_on,
        l_counter    type i.
  data: lt_zint_data type standard table of zint_data with header line.
  get time.
  clear l_created_on.
  refresh lt_zint_data.
  loop at pt_idata.
    clear lt_zint_data.
    lt_zint_data-zint_id    = pv_id.
    lt_zint_data-zint_ty    = pv_ty.
    lt_zint_data-status     = 'NEW'.
Derive both the "Key" value (KEY_VAL) and the
"Command Data Date" value (CREATED_ON) to store on the Data table
    case pv_fm.
      when 'ZINT_INBOUND_INTERFACE_CSSORDR'.
        if pt_idata-zint_re(2) = '01'.
          perform get_command_order_key using pt_idata-zint_re
                                              l_key_val
                                              l_created_on.
        endif.
      when 'ZINT_INBOUND_INTERFACE_CSTPORD'.
        if pt_idata-zint_re(2) = '01'.
          perform get_prod_order_key using pt_idata-zint_re
                                           l_key_val
                                           l_created_on.
        endif.
      when 'ZINT_INBOUND_INTERFACE_CSTGISS'.
        perform get_sales_order_key using pt_idata-zint_re
                                        l_key_val.
    endcase.
    lt_zint_data-created_on = l_created_on.
    lt_zint_data-key_val    = l_key_val.
    lt_zint_data-length     = strlen( pt_idata-zint_re ).
    lt_zint_data-raw_data   = pt_idata-zint_re.
    append lt_zint_data.
  endloop.
Setup the sequence number for each key value
  loop at lt_zint_data.
    at new key_val.
      clear l_seq.
    endat.
    add 1 to l_seq.
    lt_zint_data-sequence = l_seq.
    modify lt_zint_data.
  endloop.
Check for existing data with this same key
  clear l_counter.
  select count(*) from zint_data into l_counter
    for all entries in lt_zint_data
    where zint_id    = lt_zint_data-zint_id
    and   zint_ty    = lt_zint_data-zint_ty
    and   created_on = lt_zint_data-created_on
    and   key_val    = lt_zint_data-key_val
    and   sequence   = lt_zint_data-sequence.
Found duplicate data?
  if l_counter > 0.
Yes: so remove these records from the input table
    loop at lt_zint_data.
      clear l_counter.
      select count(*) from zint_data into l_counter
        where zint_id    = lt_zint_data-zint_id
        and   zint_ty    = lt_zint_data-zint_ty
        and   created_on = lt_zint_data-created_on
        and   key_val    = lt_zint_data-key_val
        and   sequence   = lt_zint_data-sequence.
      if l_counter > 0.
        delete lt_zint_data.
      endif.
    endloop.
    message i999(b1) with 'Data already exists in SAP! Directory:' pv_ib
                          'Key:' lt_zint_data-key_val.
  endif.
Now save whatever is not a duplicate
  loop at lt_zint_data.
Store new data records
    insert zint_data from lt_zint_data.
and Store totals for reporting
    tbl_totals-zint_id    = lt_zint_data-zint_id.
    tbl_totals-zint_ty    = lt_zint_data-zint_ty.
    tbl_totals-created_on = lt_zint_data-created_on.
    tbl_totals-count      = 1.
    collect tbl_totals.
  endloop.
endform.                    "write_data
*&      Form  get_command_order_key
      Extract Command Order from raw data
     -->L_LINE     text
     -->L_KEY      text
form get_command_order_key using l_line l_key l_date.
  data: l_orddate    type d,
        l_order(12)  type n,
        l_data(3000) type c,
        l_shortorder(5) type n.
  l_data = l_line.
  perform extract_field(saplzint_csord)
    using    l_data
    changing l_data
             l_orddate.
  perform extract_field(saplzint_csord)
    using    l_data
    changing l_data
             l_order.
  l_shortorder = l_order.
  if l_order le 9999.
    concatenate l_orddate+2(6) '-'
                l_shortorder
      into      l_key.
  else.
    concatenate l_orddate+2(6)
                l_shortorder
      into      l_key.
  endif.
  l_date = l_orddate.
endform.                    "get_command_order_key
*&      Form  get_prod_order_key
      Extract Commant Ticket number from raw data
     -->L_LINE     text
     -->L_KEY      text
form get_prod_order_key using l_line l_key l_date.
  data: l_ticketdate type d,
        l_data(3000) type c,
        l_ticket(10) type n.
  l_data = l_line.
  perform extract_field(saplzint_cstik)
    using    l_data
    changing l_data
             l_ticketdate.
  perform extract_field(saplzint_cstik)
    using    l_data
    changing l_data
             l_ticket.
  l_key = l_ticket.
  l_date = l_ticketdate.
endform.                    "get_prod_order_key
*&      Form  get_sales_order_key
      text
     -->L_LINE     text
     -->L_KEY      text
form get_sales_order_key using l_line l_key.
  l_key = l_line(10).
endform.                    "get_sales_order_key
*&      Form  read_data
      Read data from custom table
     -->PT_ZINT_DATA   text
     -->P_STATUS   text
form read_data tables pt_zint_data structure zint_data
               changing p_rtcod.
  data: lt_zint_data type standard table of zint_data with header line.
  data: l_found_rec(1) type c.
  clear p_rtcod.
  refresh: pt_zint_data, lt_zint_data.
Read stored data in date/time order
  select * from zint_data into table lt_zint_data
    where zint_id = p_intid
    and   zint_ty = p_intty
    and   status in ('ERR','NEW')
    and   created_on in s_datum
    order by created_on key_val sequence.
Always ensure any existing Error records are re-processed first.
  loop at lt_zint_data where status = 'ERR'.
    move lt_zint_data to pt_zint_data.
    append pt_zint_data.
Store totals for reporting
    tbl_totals-zint_id    = p_intid.
    tbl_totals-zint_ty    = p_intty.
    tbl_totals-created_on = lt_zint_data-created_on.
    tbl_totals-count      = 1.
    collect tbl_totals.
  endloop.
Loop through the NEW records - add to list if no other errors
  loop at lt_zint_data where status = 'NEW'.
    l_found_rec = 'N'.
    loop at pt_zint_data where status = 'ERR'
                         and   created_on <> lt_zint_data-created_on.
      l_found_rec = 'Y'.
      exit.
    endloop.
Found no errors for another date - so add NEW data
    if l_found_rec = 'N'.
      move lt_zint_data to pt_zint_data.
      append pt_zint_data.
Store totals for reporting
      tbl_totals-zint_id    = p_intid.
      tbl_totals-zint_ty    = p_intty.
      tbl_totals-created_on = lt_zint_data-created_on.
      tbl_totals-count      = 1.
      collect tbl_totals.
    endif.
  endloop.
endform.                    "read_data
                  UNDER THIS THERE IS BELOW PROGRAM
*&  Include           ZINT_CSTPORD_ROUTINES                            *
Report:      ZINT_CSTPORD_ROUTINES
Description: REDDIES Interfaces: COMMAND-SAP Interface Forms (Tickets)
Routines fpr the COMMAND-SAP production order interface. Note: some
of the code in this file has been directly copied from the original
interface (ZPPU_COMMAND_PRODUCTION, Jason Moore, Extend). This has
been done for two reasons: (1) the code works and (2) to save time.
Change History:
Date        User  Request     Description
13/02/2006  EDWG  WG1K902600  Original program.
*&      Form  process_inbound_data
      Create prod. orders from ticket data extracted from the COMMAND
      system. Note that large portions of the code in this routine
      have been copied from the retired ZPPU_COMMAND_PRODUCTION
      interface program. This was done (1) because the old code works
      and (2) to save development time.
     -->T_ZINT_IDATA  Internal table of interface data
     -->T_ZINT_PARAM  Internal table of interface parameters
     -->T_ZINT_MSLOG  Internal table of messages
     -->P_ZINT_ID     Interface ID
     -->P_ZINT_TY     Inteface type
     -->P_ZINT_IS     IDOC group for interface
     -->P_ZINT_DL     Flag: delete IDOC group when complete
     -->P_ZINT_AL     Flag: run in standalone mode
     -->P_ZINT_NW     Flag: do not log warning messages
     -->P_ZINT_SQ     Interface sequence number
     <--P_ZINT_RC     Return code (<>0=>error)
form process_inbound_data  tables   t_zint_idata structure zint_idata
                                    t_zint_param structure zint_param
                                    t_zint_mslog structure zint_mslog
                           using    p_zint_id    type      zint_id
                                    p_zint_ty    type      zint_ty
                                    p_zint_is    type      zint_is
                                    p_zint_dl    type      zint_dl
                                    p_zint_al    type      zint_al
                                    p_zint_nw    type      zint_nw
                                    p_zint_sq    type      zint_sq
                           changing p_zint_rc    type      zint_rc.
  data: lva_partner(10)   type n,
        lva_cmdord(12)    type n,
        lva_prodmat(18)   type n,
        lva_filemat(18)   type n,
        lva_prodord(12)   type n,
        lwa_file          type ty_file,
        lva_type(2)       type c,
        lva_satsur        type c,
        lva_mincart       type c,
        lva_text(200)     type c,
        lva_counter       type i,
        bblines           type i,
        lva_shortorder(5) type n,
        lva_loggr         like marc-loggr,
        lva_saleord       like vbkd-vbeln,
        lva_linkindex     like sy-tabix,
        lva_xabln         like likp-xabln,
        lva_vbeln         like likp-vbeln,
        l_vbfa            like vbfa,
        lva_igmng         like caufv-igmng,
        lva_gamng         like caufv-gamng,
        lva_qdiff         like caufv-gamng,
        lva_ltxa1         like afru-ltxa1,
        lva_aufnr         like afru-aufnr,
        lva_wemng         like afpo-wemng,
        lva_psmng         like afpo-psmng,
        lva_rsnum         like resb-rsnum,
        lva_rspos         like resb-rspos,
        l

Hi ,
Modify your code like this .
DATA: YEARS TYPE TFMATAGE,
MONTHS TYPE TFMATAGE.
*declare the variable as type Char
DATA: Y_NUM(4) TYPE c,
M_NUM(2) TYPE c.
IF NOT SOURCE_FIELDS-/BIC/ZDOB IS INITIAL.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = SOURCE_FIELDS-/BIC/ZDOB
I_DATE_TO = SY-DATUM
I_FLG_SEPARATE = 'X'
IMPORTING
E_MONTHS = MONTHS
E_YEARS = YEARS.
Y_NUM = YEARS.
M_NUM = MONTHS.
CONCATENATE Y_NUM '.' M_NUM INTO RESULT.
This will solve your problem.
MM

Similar Messages

  • Problem in SAP standard code modification for FB03

    Hi Experts,
    I am adding 4custom fields in FB03 tcode by doing a SAP standard code modification in SE51.
    The program name is SAPMF05L and screen no. is 302(In some SAP verion, it is 304). This is the screen for document line item of an invoice.
    My problem is:
    When I add the fields in the screen, in which module will I put logic in the PBO and PAI as I am unable to figure out the German comments and the program structuring.
    Also, if anybody can tell me what to write as I am little bit confused about the logic of populating my fields with the values.
    FB03 is a display transaction so I have to keep my custom screen fields disabled.
    Regards,
    Sangeeta.

    Hi Sangeeta,
    For enhancing the screen of this Tcode, first of all search is there any Screen enhancement is provided by SAP or not and in case if it is provided then use that only.
    Regards
    Jagesh Lakdawala

  • RE: Abap Code Flow for Multiple Authorization checks

    Hi all,
    I am basically a security person, but i have some doubts on Authority-check in ABAP code. so i thought this is best place to understand the execution of ABAP code.
    Q1. I know that ABAP programmers will put Authority check in ABAP code and when program was executed Authority-check will compare whether user has access to this object or not.
    for EX take some tcode ZXYY
    i activated 3 objects out of some 20 objects for this tcode in SU24.
    Authority checks are placed in the program.
    when this tcode was executed and started the ABAP code, then i think it will do the authority check for the first object and if user has the profile to it then it will go for the second authority-check for which if user does not had profile ( i made inactive in role)  will the code terminate  and throw some error there it self or will it go for the for 3rd object for which again user has access. (user got access to this 3rd object)
    can any explain?
    Q2. Should the activities be same as in Authority-check.
    I mean in Authority check if you give activities 02 and 03  and in user profile if i give only 02 will it work or not?
    thanks,
    Sun

    Refer Below Code:
    IF SY-TCODE = 'CJ40'.
         AUTHORITY-CHECK OBJECT 'ZPS_VERSN'    "'ZWMM_WERK'
            ID 'VERSN' FIELD bpdy-VERSN
            ID 'ACTVT' FIELD '01'
            ID 'ACTVT' FIELD '02'
            ID 'ACTVT' FIELD '03' .
           IF SY-SUBRC = 0.
    *        continue.
           elseif SY-SUBRC <> 0.
             AUTHORITY-CHECK OBJECT 'ZPS_VERSN'    "'ZWMM_WERK'
               ID 'VERSN' FIELD bpdy-VERSN
               ID 'ACTVT' FIELD '01'.
               IF sy-subrc = 0.
    *            CONTINUE.
               ELSEIF sy-subrc <> 0.
                  AUTHORITY-CHECK OBJECT 'ZPS_VERSN'    "'ZWMM_WERK'
                   ID 'VERSN' FIELD bpdy-VERSN
                   ID 'ACTVT' FIELD '02'.
                   IF sy-subrc eq 0 .
    *                CONTINUE.
                   ELSEIF sy-subrc <> 0 .
                     AUTHORITY-CHECK OBJECT 'ZPS_VERSN'    "'ZWMM_WERK'
                      ID 'VERSN' FIELD bpdy-VERSN
                      ID 'ACTVT' FIELD '03'.
                      IF sy-subrc = 0.
                        versn = bpdy-versn.
                        v_proj = proj-pspid.
                        wbs = PRPS-POSID.
                        set PARAMETER ID 'PSP' FIELD  v_proj.
                        set PARAMETER ID 'BP2' FIELD  VERSN.
                        set PARAMETER ID 'PRO' FIELD  wbs.
                        LEAVE TO TRANSACTION 'CJ41' AND SKIP FIRST SCREEN.
                      ELSEIF sy-subrc ne 0.
                        MESSAGE 'You are not authorised for this version.' TYPE 'E'.
                      ENDIF.
                   ENDIF.
               ENDIF.
             ENDIF.
       ENDIF.

  • Abap code used for reporting

    Hi Gurus;
    Can some one send me the abap codes used mainly for reporting OR can some one give me some sample code used in reporting. my mail id "[email protected]".

    smod > rsr0001 > EXIT_SAPLRRS0_001 > ZXRSRU01 >
    CASE I_VNAM.
    WHEN 'ZE_FPPT'.
        CALL FUNCTION 'Z_VAR_FP4'
          EXPORTING
            I_VNAM        = i_vnam
            I_STEP        = i_step
            I_T_VAR_RANGE = I_T_VAR_RANGE
          IMPORTING
            E_T_RANGE     = E_T_RANGE.
    FUNCTION Z_VAR_FP4.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(I_VNAM) LIKE  RSZGLOBV-VNAM
    *"     REFERENCE(I_STEP) TYPE  I DEFAULT 0
    *"     REFERENCE(I_T_VAR_RANGE) TYPE  RRS0_T_VAR_RANGE
    *"  EXPORTING
    *"     VALUE(E_T_RANGE) TYPE  RSR_T_RANGESID
    data: l_s_range type rsr_s_rangesid.
    data: LOC_VAR_RANGE LIKE RRRANGEEXIT.
    data: year(4).
    data: mth(2).
    IF I_STEP = 2 .
      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE
            ( VNAM = '0I_FPER' ).
          year = LOC_VAR_RANGE-HIGH+0(5).
          mth = LOC_VAR_RANGE-HIGH+5(2).
               if mth < 10.
            concatenate '0' mth into mth.
          endif.
          concatenate year '0' mth into L_S_RANGE-HIGH.
          L_S_RANGE-SIGN = 'I'.
          L_S_RANGE-OPT  = 'EQ'.
          APPEND L_S_RANGE TO E_T_RANGE.
        ENDLOOP.
      ENDIF.
    ENDFUNCTION.
    Regards,
    BWer
    Assign points if helpful.
    Message was edited by: BWer

  • ABAP code Help for Customer Exit variable

    Hello All,
    Can anyone provide ABAP code for a customer exit variable please?
    Requirement:
    0CALYEAR(InfoObject) - ZCALCYR (Variable) <b>Calender year with default value actual year</b>.
    Proiperties of variable: single value,mandatory,ready for input,can'be changed in query navigation.
    i have read some docs on customet exit variables which i got from SDN but i found it's difficult for me to get this as i am not that good in ABAP.
    Thanks,
    Rakesh.

    Hi,
       Just check the below code. You just need to make slight changes I believe. Hope this helps you.
    In CMOD………..
    Sample code
      INCLUDE LXRSRF01                                                   *
    data: l_s_range type rsr_s_rangesid.
    case i_vnam.
      when 'ZCALCYR'.
        if i_step = 1.
         l_s_range-low = sy-datum+0(4).
            append l_s_range to e_t_range.
        Endif.
    Endcase.

  • ABAP code help for Bex broadcasting by event!

    Hello
    I'm trying to broadcast a report for a specific time period as per factory calendar. I tried using System Time Point :RSRD_BROADCAST_FOR_TIMEPOINT but its not showing when In the broadcaster when I put restriction of factory calendar so i followed below link: Broadcasting timepoint scheduled after an event and created a PC to start after event and created variant for RSRD_BROADCAST_STARTER setting ID as my Bes broadcast setting technical name.
    When I trigger the event its processed and report emailed to me as I expected. Now I want to run this (Trigger) this event every Wed day after fisc quarter close. I wrote the below logic in se38 PROGRAM. But Now I need little help on how to trigger /run only on wed days after fisc quarter close ? Please update the below code or guide me on how to achieve this.
        CALL FUNCTION 'BP_EVENT_RAISE'
          EXPORTING
            EVENTID = ZFISC
      endif.
    Thanks

    in your ABAP code try this,
    calculate whether current date falls after fiscal year quarter. If so then check whether its a Wednesday and call the event raise FM. You can schedule this program in background daily basis.
    Use this FM for day calculation DATE_TO_DAY.
    This FM for converting sy-datum to fiscal year/period - FI_PERIOD_DETERMINE,DATE_TO_PERIOD_CONVERT

  • Debug ABAP code used for ABAP mapping

    Hi Experts,
    I have worked on Abap mapping. I have executed the code in SE24 to acheive desired mapping and the desired output is also generated.
    attached below is a part of the code i have used:
    method IF_MAPPING~EXECUTE.
    * initialize iXML
      TYPE-POOLS: ixml.
      CLASS cl_ixml DEFINITION LOAD.
    * create main factory
      DATA: ixmlfactory TYPE REF TO if_ixml.
      ixmlfactory = cl_ixml=>create( ).
    * create stream factory
      DATA: streamfactory TYPE REF TO if_ixml_stream_factory.
      streamfactory = ixmlfactory->create_stream_factory( ).
    * create input stream
      DATA: istream TYPE REF TO if_ixml_istream.
      istream = streamfactory->create_istream_xstring( source ).
    * parse input document =================================================
    * initialize input document
      DATA: idocument TYPE REF TO if_ixml_document.
      idocument = ixmlfactory->create_document( ).
    * parse input document
      DATA: iparser  TYPE REF TO if_ixml_parser.
      iparser = ixmlfactory->create_parser( stream_factory = streamfactory
                                            istream        = istream
                                            document       = idocument ).
      iparser->parse( ).
    I just want to debug and see if an input is provided how does each of these methods make a difference to it.
    I tried to input some value in the SOURCE parameter on executing the code but it is not working fine.
    Could you please suggest hiw i should go about so that i can see the exact way the input Xstring is affected by each of these methods in the debugger.
    Help will be appreciated.
    Many thanks,
    Neha
    Edited by: Neha Nagrani on Jul 7, 2008 11:46 AM

    Hi Neha,
    Write a Small Report as Folows:
    1.  Create your XMl payload of Type xSTRING.
    2.  Call the method EXECUTE
    Place a Breakpoint on the method. and then keep debugging inside.
    the SetParamter method is obviously called from inside.
    This is the Simplesrt Solution.
    Reward points if useful
    Regards,
    Abhishek

  • Info Spoke-ABAP Code Modification

    Hi,
       The below code is used as a customer exit variable Which give te YEAR TO DATE value on a KF.
    Could you please mofify this,That output will be year to date value & to eliminate '0' values and have to use it in Infospokes
    OUT PUT: If i use this  on a sales Qty KF,The  user enters the week so that it has to display sales qty againist dept starting from the year to the selected week and also should display only values that are NON Zero
    I need to use this in info spoke
    WHEN 'ZYTD'.
    CLEAR l_s_range.
    wdate = ww_date.
    weekno = '01'.
    SELECT SINGLE * FROM /bic/pycalday_w
    WHERE /bic/ycalday_w = wdate
    AND objvers = 'A'.
    thisweek = /bic/pycalday_w-/bic/ylwk_w.
    CONCATENATE thisweek(4) weekno INTO firstweek.
    l_s_range-low = firstweek.
    l_s_range-high = thisweek.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    APPEND l_s_range TO e_t_range.
    Thanks

    I think there is some problem with your ABAP program.
    Have you used OPEN DATASET statement, if so check if you have mentioned file path etc correctly.
    Can you try debugging the code.
    Hope this helps.

  • ABAP code help for 2004s

    Hey All,
    Could any one suggest a replacement code for the below 3.5 code in 2004s.
    If Movetype = 101 or 102 I want to update the result else I dont want to update that field. I couldnt find raise exception for thid in 2004s. Any other way to do it.
    IF COMM_STRUCTURE-MOVETYPE = '101' or COMM_STRUCTURE-MOVETYPE = '102'.
      RESULT = 'F'.
    ELSE.
    if the returncode is not equal zero, the result will not be updated
      RETURNCODE = 1.
    ENDIF.
    in 2004s
    IF SOURCE_FIELDS-MOVETYPE = '101' or SOURCE_FIELDS-MOVETYPE = '102'.
         RESULT = 'F'.
    ELSE
    *--  fill table "MONITOR" with values of structure "MONITOR_REC"
    *-   to make monitor entries
    ... "to cancel the update process
       raise exception type CX_RSROUT_ABORT.
    ... "to skip a record
       raise exception type CX_RSROUT_SKIP_RECORD.
    ... "to clear target fields
       raise exception type CX_RSROUT_SKIP_VAL.
    ENDIF.
    raise exception type CX_RSROUT_SKIP_VAL. looks to be close but it doesnt work. Can anyone explain what exactly the raise exception type CX_RSROUT_SKIP_VAL. does.
    Thanks,
    KK

    KK,
    From the comment, it is obvious that CX_RSROUT_SKIP_VAL clears the contents of the field. If you want to keep the value that was sent by the source system, just don't do anything. Don't even raise an exception.
    IF SOURCE_FIELDS-MOVETYPE = '101' or SOURCE_FIELDS-MOVETYPE = '102'.
      RESULT = 'F'.
    ENDIF.
    If the above code doesn't work, then you might try saving the value temporarily and then reassigning it.
    l_var = result.
    IF SOURCE_FIELDS-MOVETYPE = '101' or SOURCE_FIELDS-MOVETYPE = '102'.
      RESULT = 'F'.
    ELSE
      result = l_var.
    endif.

  • Abap code Logic for splitting is not working

    Hi,
    I have a requirement to split a single amount and product into several parts. so far my logic is not working as only the first row is being fetched.
    TYPES: BEGIN of map_tab,
             ZPRODH4 TYPE NEWMAPPINGTABLE-/BIC/ZNEW_MP,
             ZSPRATIO TYPE NEWMAPPINGTABLE-/BIC/ZSP_RATIO,
             ZMATERIAL TYPE NEWMAPPINGTABLE-MATERIAL,
           END OF map_tab.
    Data:IT_MAP_TAB TYPE HASHED table of MAP_TAB with unique Key ZPRODH4,
         wa_it_map_tab like line of IT_MAP_TAB.
    Data rp TYPE _ty_s_TG_1.
    LOOP AT RESULT_PACKAGE into rp.
    Clear wa_it_map_tab.
    read table IT_MAP_TAB into wa_it_map_tab with table key ZPRODH4 =
    rp-prodh4.
    IF sy-subrc EQ 0.
    select SINGLE /BIC/ZNEW_MP /BIC/ZSP_RATIO MATERIAL into corresponding
    fields of wa_it_map_tab from NEWMAPPINGTABLE
    where  PRODH4 = rp-PRODH4.
    IF sy-subrc EQ 0.
      rp-PRODH4 = wa_it_map_tab-ZPRODH4.
      rp-AMOUNT = rp-AMOUNT * wa_it_map_tab-Zspratio.
      rp-MATERIAL = wa_it_map_tab-ZMATERIAL.
    ENDIF.
    ENDIF.
    MODIFY RESULT_PACKAGE FROM rp.
    ENDLOOP.
    <br><br>
    This is how my tables looks like
    Source Table
    PROD                                       AMOUNT
    900006600999                          1000
    400004400000                           500
    NEW MAPPING TABLE
    PROD                                      NEWPROD                      MATERIAL                             SPLITRATIO
    900006600999                         1000066001111                    7000                                         0.5
    900006600999                         1000066002222                    7001                                         0.4
    900006600999                         1000066003333                    7002                                         0.1
    OLD MAPPING TABLE
    PROD                              MATERIAL
    4000044000000               7100
    TARGET TABLE
    PROD                        PROD3               MATERIAL        AMOUNT
    1000066001111         100006600            7000                 500            
    1000066002222         100006600            7001                 400          
    1000066003333         100006600            7002                 100
    4000044000000         400004400            7100                 500

    Hi,
    I rewrote the code the like this and it is still not working as the new value is not being fetched.
    {* TABLES: ...
    Defining tables
    Tables: /BIC/OLDTABLE,/BIC/NEWTABLE.
    $$ end of global - insert your declaration only before this line -
    The follow definition is new in the BW3.x
    TYPES:
    BEGIN OF DATA_PACKAGE_STRUCTURE.
    INCLUDE STRUCTURE /BIC/CS8ZSEM_TC03.
    TYPES:
    RECNO LIKE sy-tabix,
    END OF DATA_PACKAGE_STRUCTURE.
    DATA:
    DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE
    WITH HEADER LINE
    WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    New Material table
    DATA: BEGIN OF I_S_NEWTAB,
    PRODH4 TYPE /BIC/NEWTABLE-PRODH4,
    /BIC/ZNEW_MP TYPE /BIC/NEWTABLE-/BIC/ZNEW_MP,
    /BIC/ZSP_RATIO TYPE /BIC/NEWTABLE-/BIC/ZSP_RATIO,
    MATERIAL TYPE /BIC/NEWTABLE-MATERIAL,
    END OF I_S_NEWTAB.
    Data: i_t_newtab LIKE TABLE OF I_S_NEWTAB.
    *Old Material table
    DATA: BEGIN OF I_S_OLDTAB,
    PRODH4 TYPE /BIC/OLDTABLE-PRODH4,
    MATERIAL TYPE /BIC/OLDTABLE-MATERIAL,
    END OF I_S_OLDTAB.
    DATA: i_t_oldtab like table of I_S_oldTAB.
    data: e_s_result type STANDARD TABLE OF DATA_PACKAGE_STRUCTURE WITH
    HEADER LINE
    WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    data: e_t_result type STANDARD TABLE OF DATA_PACKAGE_STRUCTURE WITH
    HEADER LINE
    WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    data: amount type DATA_PACKAGE_STRUCTURE-/BIC/AMOUNT.
    data: CUSTSOLD type DATA_PACKAGE_STRUCTURE-/BIC/CUSTSOLD.
    selecting data from new table
    Select PRODH4 /BIC/ZNEW_MP /BIC/ZSP_RATIO MATERIAL FROM /BIC/NEWTABLE
    into corresponding fields of table i_t_newtab.
    SORT i_t_newtab by PRODH4.
    Selecting data from old material table
    Select PRODH4 MATERIAL FROM /BIC/OLDTABLE into corresponding fields
    of table i_t_oldtab.
    SORT i_t_oldtab by PRODH4.
    LOOP AT DATA_PACKAGE INTO e_s_result.
    read table i_t_oldtab into i_s_oldtab with key PRODH4 =
    e_s_result-PRODH4.
    if sy-subrc EQ 0.
    MOVE i_s_oldtab-PRODH4 to e_s_result-PRODH4.
    MOVE i_s_oldtab-PRODH4(14) to e_s_result-PRODH3.
    MOVE i_s_oldtab-MATERIAL to e_s_result-MATERIAL.
    APPEND e_s_result to e_t_result.
    ELSE.
    LOOP AT i_t_newtab into i_s_newtab where PRODH4 = e_s_result-PRODH4.
    amount = i_s_newtab-/BIC/ZSP_RATIO * e_s_result-/BIC/AMOUNT.
    CONCATENATE DATA_PACKAGE-SOLD_TO i_s_newtab-PRODH4(10) into AMOUNT.
    MOVE i_s_newtab-/BIC/ZNEW_MP to e_s_result-PRODH4.
    MOVE i_s_newtab-MATERIAL to e_s_result-MATERIAL.
    MOVE i_s_newtab-/BIC/ZNEW_MP(14) to e_s_result-PRODH3.
    MOVE amount to e_s_result-/BIC/AMOUNT.
    MOVE ZASTUOTE to e_s_result-/BIC/CUSTSOLD.
    APPEND e_s_result to e_t_result.
    ENDLOOP.
    ENDIF.
    ENDLOOP.
    REFRESH DATA_PACKAGE.
    MOVE e_t_result to DATA_PACKAGE[].}

  • ABAP code help for 0PROFIT_CTR  (in Update rules)

    Hi
    Can you please give me the update rules code that would do the following in BW 3.5:
    If Profit Center is 10 digits long, its ok but if Profit Center is 5 digits long, concatenate with 5 zeros.
    Thanks
    Jimi
    Edited by: jimi ogun on Dec 1, 2011 1:44 PM

    Hi Soorej
    I tried teh code in my transfer rules but the result was blank. I guess it was because i didnt insert anything in the RESULT line... This is what i tried to do but i get a syntax error:
    $$ begin of routine - insert your code only below this line        -
    DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
    data : len type i,
          v1(10) TYPE c value 'abcde'.
    len = strlen( v1 ).
    if len = 5.
    CONCATENATE v1 '00000' into v1.
    endif.
      RESULT = /BI0/OIPROFIT_CTR.
    returncode <> 0 means skip this record
      RETURNCODE = 0.
    abort <> 0 means skip whole data package !!!
      ABORT = 0.
    The syntax error i get is below:
    E:Field "/BI0/OIPROFIT_CTR" is unknown. It is neither in one of the
    specified tables nor defined by a "DATA" statement. "DATA" statement.

  • Abap Code help for retreiving user ID

    Hi All,
    I have a field N_BPIID(this field contains User IDs of Users) and variable on this field Z_PIID(Customer exit)...........
    My requirement is
    When i execute the report -
    this variable Z_PIID should automatically  retrive his ID frm BI/BW system..............
    Please suggest
    Edited by: Raj on Jan 12, 2010 4:59 AM

    Hi,
    A user that is signed on - system will populate field sy-uname - Not sure of your logic.In STEP 3 of your CMOD you could say :
    Eg : If user is not user "USERABC" then dont allow them into queries.
    Hope this helps    Colin
    IF sy-uname+0(7) <> 'USERABC'.
          L_AUTH = 0.
          EXIT.
        ENDIF.
      if sy-subrc <> 0.
        CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
          EXPORTING
            I_CLASS  = 'RSBBS'
            I_TYPE   = 'E'
            I_NUMBER = '013'
            I_MSGV1  = 'Insufficient authorisation'.
        RAISE wrong_entry.
      endif.

  • Error in the ABAP Code for Customer Exit Variable

    Could you please update me what is the wrong with the below ABAP Code developed for Customer Exit Variable in BW
    i created a Variable (ZVWKNO) of Customer Exit,Single Value ,Mandatory and Variable is ready for input
    In CMOD i had written the below Code:
    When 'ZVWKNO'.
    DATA: WEEK(2) TYPE N,
    WEEKNO(2) TYPE N.
    IF i_step = 1.
    l_st_date = SY-DATUM.
    CALL FUNCTION 'DATE_GET_WEEK'
    EXPORTING
    DATE = l_st_date
    IMPORTING
    WEEK = l_fn_week.
    CHECK sy-subrc = 0.
    WEEK = l_fn_week+4(2).
    If WEEK 0.
    WEEKNO = WEEK - 1.
    l_s_range-low = WEEKNO.
    l_s_range-sign = k_sign_inclusive.
    l_s_range-opt = k_option_equals.
    APPEND l_s_range to e_t_range.
    ENDIF.
    ENDIF.
    But when i execute the query the default value is not populated with Week-1 No in the variable screen
    Please update me what went wrong
    Thanks

    Case ZVWKNO.                "write this with out comments
    When '1'.              "write the value that needs to equal with value in varaible ZVWKNO after when in sungle quotes
    DATA: WEEK(2) TYPE N,
    WEEKNO(2) TYPE N.
    IF i_step = 1.
    l_st_date = SY-DATUM.
    CALL FUNCTION 'DATE_GET_WEEK'
    EXPORTING
    DATE = l_st_date
    IMPORTING
    WEEK = l_fn_week.
    CHECK sy-subrc = 0.
    WEEK = l_fn_week+4(2).
    If WEEK 0.                                    "check this Week Minimum is '01' and Maximum '52'
    WEEKNO = WEEK - 1.
    l_s_range-low = WEEKNO.
    l_s_range-sign = k_sign_inclusive.
    l_s_range-opt = k_option_equals.
    APPEND l_s_range to e_t_range.
    ENDIF.
    ENDIF.
    Prabhudas

  • Implement activation key in ABAP code

    In short:
    I want to implement a way to control if certain ABAP code (certain logicial areas) are executed, by having the ABAP code prompting for an activation key.
    Much like when you are promptet for a Developer access key or an object key for chaning sap standard code.
    The long explanation:
    We have som local developement in our system landscape that we want subsiduraies to request an access key if they want to go beond a certain point (or if they want to use this logical part of the develoment).
    They should be promptet for an access key - which they then request from the head office.
    A case could also be if we are developing an SAP Add-on using AAK (Add-on Assemply Kit) and we want to close of certain areas of functionality, these areas of functionality could then be opened by a access key requested from headoffice.
    Question
    Do you know how to impelment an access key feature in ABAP?

    For programs (SE38), you may implement EXIT_SAPLS38E_001 of extension SEUED001 (using CMOD transaction) to keep users from modifying programs:
    IF operation = 'EDIT' AND
       program IN <reserved_to_head_office> AND
       sy-uname NOT IN <head_office_team>.
      MESSAGE i001(00) WITH 'program reserved exclusively to head office'.
      RAISE cancelled.
    ENDIF.
    For function modules (SE37), you may implement EXIT_SAPLS38L_001 of extension SEU00004:
    IF operation = 'MODIFY' AND
       objectname IN <reserved_to_head_office> AND
       sy-uname NOT IN <head_office_team>.
      MESSAGE e001(00) WITH 'this FM is reserved exclusively to head office'
              RAISING cancelled.
    ENDIF.
    For methods (SE24), I don't know how to do it. I guess implicit enhancement option should be used.
    Edited by: Rob Burbank on Mar 22, 2010 6:40 PM

  • How to call a transaction from ABAP code

    Hi everybody,
    How do I run a transaction from my ABAP code?
    For example, through my ABAP code, I want to call the ME24 transaction (Maintain Purchase Order).
    Thanks for the help,
    Roy

    CALL TRANSACTION
    Syntax
    CALL TRANSACTION ta { [AND SKIP FIRST SCREEN]
                        | [USING bdc_tab [bdc_options]] }.
    Extras:
    1. ... AND SKIP FIRST SCREEN
    2. ... USING bdc_tab [bdc_options]
    Effect
    The statement CALL TRANSACTION calls the transaction whose transaction code is contained in data object ta. The data object ta must be of character type and must contain the transaction code in uppercase letters. If the transaction specified in ta cannot be found, an untreatable exception is triggered. The additions suppress the display of the initial screen and allow you to execute the transaction using a batch input session.
    At CALL TRANSACTION the calling program and its data is kept, and after exiting the called transaction, processing is resumed in the calling program after the call.
    When the transaction is called, the ABAP program linked with the transaction code is loaded in a new internal session. The session of the calling program is kept. The called program runs in an SAP LUW of its own.
    If the called transaction is a dialog transaction, after loading the ABAP program the event LOAD-OF-PROGRAM is triggered and the dynpro defined as initial dynpro of the transaction is called. The initial dynpro is the first dynpro of a dynpro sequence. The transaction is finished when the dynpro sequence is ended by encountering the next dynpro with dynpro number 0 or when the program is exited with the LEAVE PROGRAM statement.
    If the called transaction is an OO transaction (as of release 6.10), when loading all programs except class pools the event LOAD-OF-PROGRAM is triggered and then the method linked with the transaction code is called. If the method is an instance method, implicitly an object of the corresponding class is generated and referenced by the runtime environment. The transaction is finished when the method is finished or when the program is exited using the LEAVE PROGRAM statement.
    After the end of the transaction call, program execution of the calling program resumes after the CALL TRANSACTION statement.
    Note
    At the statement CALL TRANSACTION, the authorization of the current user to execute the called transaction is not checked automatically. If the calling program does not execute a check, the called program must check the authorization. To do this, the called program must call function module AUTHORITY_CHECK_TCODE.
    Addition 1
    ... AND SKIP FIRST SCREEN
    Effect
    This addition suppresses the display of a screen of the initial dynpro of a called dialog transaction. The addition AND SKIP FIRST SCREEN suppresses the first screen under these prerequisites:
    For the initial dynpro, in the Screen Painter the own dynpro number must not be specified as the next screen number.
    All mandatory input fields of the initial dynpro must be filled completely and with the correct values by the SPA/GPA parameters
    If these prerequisites are met, that screen of the dynpro is displayed that is specified in the Screen Painter as the next dynpro of the initial dynpro.
    Example
    If the static next dynpro of the initial dynpro of the called dialog transaction FLIGHT_TA is not the initial dynpro itself, its screen is suppressed, because its input fields are filled using the SPA/GPA parameters CAR and CON.
    DATA: carrid TYPE spfli-carrid,
          connid TYPE spfli-connid.
    SET PARAMETER ID: 'CAR' FIELD carrid,
                      'CON' FIELD connid.
    CALL TRANSACTION 'FLIGHT_TA' AND SKIP FIRST SCREEN.
    Addition 2
    ... USING bdc_tab [bdc_options]
    Effect
    Use this addition to pass an internal table bdc_tab of row type BDCDATA from the ABAP Dictionary to a dialog transaction. The additions bdc_options control the batch input processing. When a transaction with addition USING is called, the system field sy-binpt is set to value "X" in the called program - while this transaction is running, no other transaction can be called with this addition.
    The internal table bdc_tab is the program-internal representation of a batch input session and must be filled accordingly. The structure BDCDATA has the components shown in the table below.
    Component Description
    PROGRAM Name of the program of the called transaction
    DYNPRO Number of the dynpro to be processed
    DYNBEGIN Flag for the beginning of a new dynpro (possible values are "X" and " ")
    FNAM Name of a dynpro field to be filled or batch input control statement, for example, to position the cursor
    FVAL Value to be passed to the dynpro field or to the control statement
    Using the internal table bdc_tab, you can provide any number of screens of the called transaction with input and user actions.
    System Fields
    sy-subrc Description
    0 The batch input processing of the called transaction was successful.
    < 1000 Error in the called transaction. If within the transaction a message was sent, you can receive it using the addition MESSAGES.
    1001 Error in batch input processing.
    Note
    Outside of ABAP Objects you can specify the additions AND SKIP FIRST SCREEN and USING together. However, this does not make sense, because the addition AND SKIP FIRST SCREEN is desigend only to fill the mandatory input fields using SPA/GPA parameters, while the batch input table specified with USING controls the entire transaction flow including the display of the screens.
    Example
    Call of the Class Builder (transaction SE24) and display of class CL_SPFLI_PERSISTENT. The internal table bdcdata_tab contains the input for the batch input processing of the first dynpro (1000) of the transaction. Using structure opt, the batch input processing is set to suppress the first screen and to display the next screen in the standard size.
    DATA class_name(30) TYPE c VALUE 'CL_SPFLI_PERSISTENT'.
    DATA: bdcdata_wa  TYPE bdcdata,
          bdcdata_tab TYPE TABLE OF bdcdata.
    DATA opt TYPE ctu_params.
    CLEAR bdcdata_wa.
    bdcdata_wa-program  = 'SAPLSEOD'.
    bdcdata_wa-dynpro   = '1000'.
    bdcdata_wa-dynbegin = 'X'.
    APPEND bdcdata_wa TO bdcdata_tab.
    CLEAR bdcdata_wa.
    bdcdata_wa-fnam = 'BDC_CURSOR'.
    bdcdata_wa-fval = 'SEOCLASS-CLSNAME'.
    APPEND bdcdata_wa TO bdcdata_tab.
    CLEAR bdcdata_wa.
    bdcdata_wa-fnam = 'SEOCLASS-CLSNAME'.
    bdcdata_wa-fval = class_name.
    APPEND bdcdata_wa TO bdcdata_tab.
    CLEAR bdcdata_wa.
    bdcdata_wa-fnam = 'BDC_OKCODE'.
    bdcdata_wa-fval = '=CIDI'.
    APPEND bdcdata_wa TO bdcdata_tab.
    opt-dismode = 'E'.
    opt-defsize = 'X'.
    CALL TRANSACTION 'SE24' USING bdcdata_tab OPTIONS FROM opt.

Maybe you are looking for

  • LabView Run-time engine 6.1 fatal error on install in XP Pro

    I downloaded an application which uses the LVRTE to decode audio signals and display them graphically. I then downloaded the latest (?) version of the RTE installer for Windows .../XP from the NI site and it shows a version number of 1.1.0.0 if I mov

  • Problem with multiple users sharing a single library

    We have a family iMac. I am the only one with Admin privileges. I want to share my iTunes music folder with the other users so we don't end up replicating all the MP3 files. I put the music folder in my Public directory and the other users can see it

  • IPhone 5 Purple/green mark in middle of screen

    My iPhone has recently developed a purple haze on the screen when using it. When I use certain apps, it turns green. It's very annoying for when I'm watching movies etc, so any help would be excellent.

  • IPod movies wont play sound

    Hi, I recently have been dragging my "movie clips" Ive taken with my camera and put them on iTunes. They work fine, but were not compatible with my iPod. Therefore, I converted the QuickTime movie files to MPEG-4 Video Files. Now, there is no sound p

  • All Day Events Showing as 24 Hour Events (Nokia N95)

    Hi, I'm syncing a Nokia N95 using the Nokia iSync plugin. My all day events are shown on the phone as 24 hour long events. Is there a way to stop this? Many thanks David