We can help. Together we learn....

Checking Log for table changes

by Voice | Thursday, April 22, 2010 in | comments (0)

SCU3 - Use this transaction if log is activated for that table. If you are unable to see the log, try debugging and by passing the one authority check.

Include - RSVTPF01, line - 2416
SELECT SINGLE * FROM tddat INTO w_tddat

By pass this error or maintain your entry in TDDAT.
View - V_DDAT_54
Note - 323636

Info - For all select

by Voice | Tuesday, May 05, 2009 in | comments (0)

1. Before doing a for all select, just make sure the internal table you are using for all select is not empty (INITIAL). If it is empty then for all select will fetch all the records in the database and thay may be a problem. So be careful.


2. Mechanism of for all select: SAP first fetches all the record and then it sort the records found and then it does a delete duplicates comparing all the fields. So, if you want to retrieve all the records, you MUST select all the key fields or else you will lose some records.

Try it for youself:
Check the number of records present in the database table and the number of records present in internal table.


REPORT  Z000_TEST_FOR_ALL_SELECT.

types: begin of ty_dd02l,
         tabname type tabname,
       end of ty_dd02l,

       begin of ty_dd03l,
         tabname type tabname,
         KEYFLAG type KEYFLAG,
       end of ty_dd03l.

data: i_dd02l type standard table of ty_dd02l initial size 0,
      i_dd03l type standard table of ty_dd03l initial size 0.

data: v_tabname type dd02l-tabname.
select-options s_table for v_tabname.

select TABNAME
   from dd02l
  into table i_dd02l
  where tabname in s_table.

IF sy-subrc = 0.
  select TABNAME
         KEYFLAG
    from dd03l
    into table i_dd03l
    for all entries in i_dd02l
    where tabname = i_dd02l-tabname.

  IF sy-subrc = 0.

  ENDIF.
ENDIF.


ABAP CRM Tips

by Biswa | Tuesday, November 04, 2008 in , | comments (3)

Tip 1: Opening CRM Order in a new window

When there is a requirement to open a CRM Order (Customer Order. Service Order. etc.) from a program, the normal process is to populate the Business Object Parameter (CRM_OBJECT_ID) with the Transaction Number (OBJECT_ID) and then doing a CALL TRANSACTION to CRMD_ORDER. But this method does not seem to work.

SET PARAMETER ID 'CRM_OBJECT_ID' FIELD .
CALL TRANSACTION 'CRMD_ORDER' AND SKIP FIRST SCREEN.

It will not get into the transaction (CRM Order) , but stop at the search screen

The way around could be using the BAPI BAPI_BUSPROCESSND_DISPLAY to display the CRM Order. You can use it to display the CRM Order screen directly. Just pass your Order Header GUID ID to the business process and the CRMD_ORDER screen will be displayed.

CALL FUNCTION 'BAPI_BUSPROCESSND_DISPLAY'
EXPORTING
business_process = <order_header_guid>

Tip 2: Inserting or Deleting Standard / Custom messages in CRM GUI.

If possible, you can follow the following steps.

a) First delete message, for example


* Deleting the messages from stack

CALL FUNCTION 'CRM_MESSAGES_DELETE'
EXPORTING
iv_caller_name = gc_object_name-order
iv_ref_object = iv_item
it_r_msgidno = lt_idno
EXCEPTIONS
OTHERS = 1.


b) Check for corresponding message text already exists or not, for example


CALL FUNCTION 'CRM_TEXT_READ_API'
EXPORTING
it_guid = lt_object_guids
iv_object_kind = gc_object_kind-orderadm_i
IMPORTING
et_text = lt_text.

OR,

Search the corresponding messages, for example,

ls_idno-sign = 'I'.
ls_idno-option = 'EQ'.
ls_idno-low-msgid = 'Z_ZZZ_CA_MESSAGES'.
ls_idno-low-msgno = '126'.

APPEND ls_idno TO lt_idno.

CALL FUNCTION 'CRM_MESSAGES_SEARCH'
EXPORTING
it_r_msgidno = lt_idno
iv_ref_object = iv_header_guid
iv_ref_kind = gc_object_kind-orderadm_h
iv_only_errors_on_object = true
IMPORTING
et_msg_info = lt_msg_info
EXCEPTIONS
appl_log_error = 1
error_occurred = 2
OTHERS = 3.


c) If message does not exist .Then raise message. for example


CALL FUNCTION 'CRM_MESSAGE_COLLECT'
EXPORTING
iv_caller_name = gc_object_name-order
iv_ref_object = iv_item
iv_ref_kind = gc_object_kind-orderadm_i
iv_logical_key = 'MAINTAIN'
iv_msgno = lv_msgno
iv_msgid = 'CRM_ORDERADM_I'
iv_msgty = lv_msgty
EXCEPTIONS
not_found = 1
appl_log_error = 2
OTHERS = 3.


Sending Inbound IDocs from a SAP Program

by Biswa | Tuesday, November 04, 2008 in , | comments (3)

In most cases, the inbound IDoc to SAP is generated by an external system (say XI) and passed on to SAP. The inbound IDoc is then processed using the process code / corresponding function module. But in certain cases, due to the client requirements, the interface program needs to be designed in such a way that the Inbound IDoc originates from within the same SAP system i.e. both the sending and receiving system are the same.

Now mostly in such requirements, we generally generate the IDoc after reading data from a flat file. The file is passed to the application server by a middleware (say XI). The SAP interface program reads the file from the application server and then starts processing the data. To create the inbound IDoc, we need to use the Function Module ‘IDOC_INBOUND_WRITE_TO_DB’. This creates and saves the IDoc to the database.

The control record information for the inbound IDoc is passed to pc_control_record (Similar to EDIDC – IDoc control record). In the control records, all relevant information like status (53); receiver port, receiver partner no.; sender port; sender partner no etc are populated. All the IDoc data is passed to internal table t_data_records (Similar to EDIDD – IDoc control record). The IDoc data is read from the incoming file and processed and then populated to internal table itab_data_records_db with segment name etc.

The inbound process data is passed to the function module.

CALL FUNCTION 'IDOC_INBOUND_WRITE_TO_DB'
exporting
pi_do_handle_error = 'X'
pi_return_data_flag = ' '

importing
pe_idoc_number = control_record_db_in-docnum
pe_inbound_process_data = wa_inbound_process_data_in

tables
t_data_records = itab_data_records_db
changing
pc_control_record = control_record_db_in
exceptions
idoc_not_saved = 1
others = 2.


Now if the inbound IDoc has been successfully created and we want to process the same, the function module ‘IDOC_START_INBOUND’ can be used. Here we pass the inbound process data containing the IDoc process code and event code to wa_inbound_process_data_in. The status and release are added to the control records internal table i_control_records.

CALL FUNCTION 'IDOC_START_INBOUND'
exporting
pi_inbound_process_data = wa_inbound_process_data_in
pi_called_online = 'X'
succ_show_flag = 'X'

tables
t_control_records = i_control_records
exceptions
others = 1.

If we have no exception, then the IDoc will be successfully processed and have status ‘53’.


Link to this post on our new blog : http://www.sapyard.com/sending-inbound-idocs-from-a-sap-program/

Some tips

by Voice | Monday, October 27, 2008 in , | comments (0)

Here are some tips which may save some time for you. And it is always fun experimenting with the things you know.

 Problem: Suppose you are dividing two numbers (in real project scenario it is used while converting amount from one currency to another currency) and there is a requirement to round off the result.

Easy solution: Suppose you need to round it off to 1 decimal position, just use a variable having data element having one decimal position while storing the result. It will be rounded off automatically.

 

Problem: When you try to assign value from character to amount variable or quantity variable, it gives short dump.

Easy solution: Before assigning value, just assign any number to the required amount variable or quantity variable. Then use the assign the character value to amount variable. It will take the value.

Keep it in mind that value in the character field should be in the same format as the variable.

 

Problem: In Sap script, sometime it is required to print values only in the last page or first page. For this we use variables like “SAPSCRIPT-FORMPAGES” or “NEXT-PAGE”. It works fine but yet people find that their script is not printing properly.

For this I don’t have any easy solution. You can only use some text element which is either called in the beginning or in the end. But I will tell you the reason why it does not work. This problem arises when you try to use these variables in MAIN window and sadly in main window these variables do not work. So even you check your form and it seems logically foolproof, you will not get desired result. It is pain taking to debug a SAP Script so we do not even check it in debug mode and keep banging our heads. This tip can be useful for them. :)

I can give you another tip like, if you want to print any line or box something like that in the end page only and that has to be a part of main window, then I will suggest, use a pseudo window, over lapping the main window. You can use the variable in that window and can use to print something like box or line at the page you desire.

Anyways if such requirement is needed, then do let me know in the comment section; will try my best to give you some alternative logic to do so.

 

Problem: In Sap script, when we do amount calculation in sub routine pool program (a z program which is called from the Sap script to do data manipulation), even we use ‘(<)’ operator to shift the negative sign to the left of the amount, it does not work.

Solution: This is again one problem which makes developers bang their heads. The problem occurs because the variable which returns the value from the Z program is type “char”.  So command like ‘(<)’ does not work. For this you have to whether the value is negative or not in the sub routine pool itself and then if it negative, then you have to remove negative sign from the right and have to concatenate minus sign in left of the value.

 

There are many tips like this which look small but are very effective. May be sometime later… and if you want to share something, please do in the comment section.

 

Categories