Table Of ContentSAP NOTEBOOK - ABAP
INTERVIEW QUESTIONS
ANSWERS TIPS
Hybris and SAP
Hybris is a e-commerce product which is now a part of SAP after SAP's acquisition.
Hybris' strong suit is supporting business-to-business (B2B) commerce, but it also supports
business-to-consumer (B2C) commerce, product content management and order
management. B2B customers include the likes of industrial products supplier Granger
while coffee equipment maker Nespresso and camera manufacturer Nikon use Hybris for
both B2B and B2C commerce.
Hybris' core architecture provides a master data-management layer said to ensure
consistent inventory, pricing, order-status and other information across channels, whether
that's Web, mobile, call center or retail stores. There's also a process-management layer
that applies the same business rules across channels, so prices and promotions
encountered online are consistent with those encountered in stores or on mobile devices.
With the Hybris acquisition completed, Sheldon says the enterprise commerce technology
landscape is now "dominated by four large software companies: SAP, IBM, Oracle and
eBay."
IBM and Oracle are clearly SAP's chief rivals, and they've both spent billions on
acquisitions in the commerce and customer experience arena. The most directly
competitive products to Hybris at IBM are Unica and Sterling Commerce, while Oracle has
ATG and commerce-oriented bits and pieces of BEA, E-Business Suite, FatWire, Stellent
and Eloqua.
Looking for Unlimited very long input text entry field in SAP ABAP
programming?
Method1: Simple: Function module for Popup
Use the function module CATSXT_SIMPLE_TEXT_EDITOR.
Just give a title for the function module and execute to give a POP UP and free text field.
The resulting ITAB will give you the text lines.
Method2: Medium : OOPS method for Free text editor
DATA editor_container TYPE REF TO cl_gui_custom_container.
create object editor_container
exporting
container_name = 'Container100'
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
b) Created a reference to your Text Edit Control and create it's object :
DATA text_editor TYPE REF TO cl_gui_textedit.
create object text_editor
exporting
parent = editor_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true. "or simply = false
c)Hide toolbar and statusbar
call method text_editor ->set_toolbar_mode
exporting
toolbar_mode = cl_gui_textedit=>false.
call method text_editor->set_statusbar_mode
exporting
statusbar_mode = cl_gui_textedit=>false.
d) Answering your question Text Edit Control --> Database Table
call method text_editor->get_text_as_stream
exporting
only_when_modified = cl_gui_textedit=>false
importing
text = wrk_text
exceptions
others = 1.
Save wrk_text to Table
e) Text Edit Control <-- database="" table="" u="">
The reverse process of Step 4
With method :
CALL METHOD text_editor->set_text_as_stream
......
How to Clear the OOPS Free text:
This is how I get rid of the existing text:
* Delete the Text
me->o_editor->delete_text( ).
* Set the new text
me->o_editor->set_textstream( EXPORTING text = iv_text ).
Set the Free text object editable and Disabled mode by using the below method.
IF condition.....
CALL METHOD G_FREETEXT_1->SET_READONLY_MODE
EXPORTING
READONLY_MODE = '1'
EXCEPTIONS
ERROR_CNTL_CALL_METHOD = 1
INVALID_PARAMETER = 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.
else.
CALL METHOD G_FREETEXT_1->SET_READONLY_MODE
EXPORTING
READONLY_MODE = CL_GUI_TEXTEDIT=>FALSE
EXCEPTIONS
ERROR_CNTL_CALL_METHOD = 1
INVALID_PARAMETER = 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.
endif.
Editable ALV event trigger without pressing enter key
Making ALV to react to Change data automatically
LINK: http://wiki.scn.sap.com/wiki/display/ABAP/Making+ALV+to+react+to+Change+data+automatically
Scenario:
To make ALV to react to data change automatically without any need for the user to click on ENTER or any
other button/menu item.
Procedure:
In order to make the system react to an edit event, we need to first register the edit event.
To register the edit event, call the method REGISTER_EDIT_EVENT
CALL METHOD cont_editalvgd -> register_edit_event
Exporting
{}I_event_id = cl_gui_alv_grid => mc_evt_modified.
When user press 'ENTER' the event MC_EVT_ENTER is triggered which automatically sets the variable
M_cell_edit to 'X'.
But if the user bypasses the enter key then the variable M_CELL_EDIT has to be set explicitly which is done by
passing mc_evt_modified to the exporting parameter I_EVENT_ID instead ofmc_evt_enter.
In the PAI event, call the method CHECK_CHANGED_DATA. This method automatically triggers
the data_changed event.
By default, SAP recognizes 'ENTER' event. When only the CHECK_CHANGED_DATA is called in PAI event,
then the 'ENTER' event is not recognized by the system. In order to have both the events recognized by the
system, we need to register the edit event.
Sample code:
REPORT Z_ALV_EDIT_EVENT.
*"Table declarations...................................................
TABLES:
SPFLI. " Flight Schedule Details
*" Data declarations...................................................
*"--------------------------------------------------------------------*
* Work variables *
*"--------------------------------------------------------------------*
DATA:
W_GRID TYPE REF TO CL_GUI_ALV_GRID, " Reference object for alv grid
W_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
" Reference object for container
*"--------------------------------------------------------------------*
* Structure to hold Flight Schedule details *
*"--------------------------------------------------------------------*
DATA:
FS_SPFLI TYPE SPFLI.
*"--------------------------------------------------------------------*
* Structure to hold Field Catalog details *
*"--------------------------------------------------------------------*
DATA:
WA_FIELD_CATALOG TYPE LVC_S_FCAT.
*"--------------------------------------------------------------------*
* Structure to hold Layout of the ALV Report *
*"--------------------------------------------------------------------*
DATA:
WA_LAYOUT TYPE LVC_S_LAYO.
*"--------------------------------------------------------------------*
* Internal table to hold Flight Schedule details from table SPFLI *
*"--------------------------------------------------------------------*
DATA:
T_SPFLI LIKE
STANDARD TABLE
OF FS_SPFLI.
*"--------------------------------------------------------------------*
* Internal table to hold Field Catalog Details *
*"--------------------------------------------------------------------*
DATA:
T_FIELD_CATALOG TYPE LVC_T_FCAT.
*"--------------------------------------------------------------------*
* START-OF-SELECTION EVENT *
*"--------------------------------------------------------------------*
START-OF-SELECTION.
* Data retrieval from the database table
SELECT * FROM SPFLI INTO TABLE T_SPFLI.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module set_layout OUTPUT
*&---------------------------------------------------------------------*
* This module is used to set the layout for the alv grid display *
*----------------------------------------------------------------------*
MODULE SET_LAYOUT OUTPUT.
WA_LAYOUT-GRID_TITLE = 'SPFLI TABLE DETAILS'.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-EDIT = 'X'.
ENDMODULE. " set_layout OUTPUT
*&---------------------------------------------------------------------*
*& Module field_catalog OUTPUT
*&---------------------------------------------------------------------*
* This module is used to populate the field catalog *
*----------------------------------------------------------------------*
MODULE FIELD_CATALOG OUTPUT.
CLEAR WA_FIELD_CATALOG.
WA_FIELD_CATALOG-FIELDNAME = 'CARRID'.
WA_FIELD_CATALOG-REF_FIELD = 'CARRIDS'.
WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'.
WA_FIELD_CATALOG-COL_POS = 1.
APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG.
CLEAR WA_FIELD_CATALOG.
WA_FIELD_CATALOG-FIELDNAME = 'CONNID'.
WA_FIELD_CATALOG-REF_FIELD = 'CONNID'.
WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'.
WA_FIELD_CATALOG-COL_POS = 2.
APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG.
CLEAR WA_FIELD_CATALOG.
WA_FIELD_CATALOG-FIELDNAME = 'CITYFROM'.
WA_FIELD_CATALOG-REF_FIELD = 'CITYFROM'.
WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'.
WA_FIELD_CATALOG-COL_POS = 3.
APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG.
CLEAR WA_FIELD_CATALOG.
WA_FIELD_CATALOG-FIELDNAME = 'CITYTO'.
WA_FIELD_CATALOG-REF_FIELD = 'CITYTO'.
WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'.
WA_FIELD_CATALOG-COL_POS = 4.
APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG.
ENDMODULE. " field_catalog OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
This module is used to handle the PAI events
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'OK'.
* Calling the check_changed_data method to trigger the data_changed
* event
CALL METHOD W_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID =
CHANGING
C_REFRESH = 'X'
.
UPDATE SPFLI FROM TABLE T_SPFLI.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE. " CASE SY-UCOMM
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module manage_alv_grid OUTPUT
*&---------------------------------------------------------------------*
This module is used to manage the Grid display
*----------------------------------------------------------------------*
MODULE MANAGE_ALV_GRID OUTPUT.
IF W_GRID IS INITIAL.
CREATE OBJECT W_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER1'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. " IF SY-SUBRC NE 0
CREATE OBJECT W_GRID
EXPORTING
I_PARENT = W_CONTAINER
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 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. " IF SY-SUBRC NE 0
CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'SPFLI'
IS_LAYOUT = WA_LAYOUT
CHANGING
IT_OUTTAB = T_SPFLI[]
IT_FIELDCATALOG = T_FIELD_CATALOG
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 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. " IF SY-SUBRC NE 0
ENDIF. " IF W_GRID IS INITIAL
Registering the EDIT Event
CALL METHOD W_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. " IF SY-SUBRC NE 0
ENDMODULE. " manage_alv_grid OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
This module is used to set the PF-Status and title bar *
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ALVS_GUI'.
SET TITLEBAR 'ALV_TITLE'.
ENDMODULE. " STATUS_0100 OUTPUT
Parallel Cursor - Simple
Improving performance in Nested loop scenario's:
How ? Instead of sequential search in each loops, we will use Read table of ITAB2 and get
the SY-TABIX of that second ITAB.
Now if sy-Subrc = 0 then proceed the loop into second ITAB and use the syntax
LOOP AT ITAB2 INTO WA FROM w_TABIX.
Use if conditions inside the loop to check the keys thereafter.
sort: lt_vbpa by kunnr, "Sorting by key is very important
lt_kna1 by kunnr. "Same key which is used for where condition is used here
loop at lt_vbpa into wa_vbpa.
read lt_kna1 into wa_kna1 " This sets the sy-tabix
with key kunnr = wa_vbpa-kunnr
binary search.
if sy-subrc = 0. "Does not enter the inner loop
v_kna1_index = sy-tabix.
loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause
if wa_kna1-kunnr <> wa_vbpa-kunnr. "This checks whether to exit out of loop
exit.
endif.
****** Your Actual logic within inner loop ******
endloop. "KNA1 Loop
endif.
endloop. " VBPA Loop
Background Job scheduling - Interview Question
SM36 -DEFINE BACKGROUND JOB - Create background Jobs
SM37 : SIMPLE JOB SELECTION - To check status ( maintenance )
Great interview preparation and knowledge making
http://saplab.blogspot.com/2007/09/difference-with-smartforms-vs.html
http://learnabap.blogspot.com/2007/05/performance-tuning-using-parallel.html
Smartform Interview questions
Found in this site:
http://saplab.blogspot.com/2007/09/smart-forms-frequently-asked-questions.html
Smart forms Frequently Asked Questions
Forcing a page break within table loop
Create a loop around the table. Put a Command node before the table in the loop that
forces a NEWPAGE on whatever condition you want. Then only loop through a subset of
the internal table (based on the conditions in the Command node) of the elements in the
Table node.
Font style and Font size
Goto Transaction SMARTSTYLES.
There you can create Paragraph formats etc just like in sapscript.
Then in your window under OUTPUT OPTIONS you include this SMARTSTYLE and use
the Paragraph and character formats.
Line in Smartform
Either you can use a window that takes up the width of your page and only has a height of
1 mm.
Then you put a frame around it (in window output options).
Thus you have drawn a box but it looks like a line.
Or you can just draw "__" accross the page and play with the fonts so that it joins each
UNDER_SCORE.
Difference between 'form interface' and 'global definitions' in global settings of
smart forms
The Difference is as follows.
To put it very simply:
Form Interface is where you declare what must be passed in and out of the smartform (in
from the print program to the smartform and out from the smartform to the print program).
Global defs. is where you declare data to be used within the smartform on a global scope.
ie: anything you declare here can be used in any other node in the form.
Description:ANSWERS TIPS · Hybris and SAP d) Answering your question Text Edit Control --> Database Table call method .. SQL Query examples: SELECT SAP Application server allocates a memory area dedicated to each user or .. The default value is 1 line; the LPI value (lines per inch) in the header