Monday, July 11, 2011
SAP APO enhancement for AFS
Saturday, October 9, 2010
The final touch (add a htmp page on SAP screen)
public section.
methods: on_sapevent
for event sapevent of cl_gui_html_viewer
importing action frame getdata postdata query_table.
endclass.
data: evt_receiver type ref to cl_myevent_handler.
* CLASS CL_GUI_CFW DEFINITION LOAD.
class cl_myevent_handler implementation.
method on_sapevent.
case action.
WHEN 'ZORD'.
CALL TRANSACTION 'ZORD'.
WHEN 'ZORD_SPLIT'.
CALL TRANSACTION 'ZORD_SPLIT'.
endcase.
endmethod.
if html_control is initial.
prog_repid = sy-repid.
create object my_container
exporting
container_name = 'HTML_CONTROL'.
create object html_control
exporting
parent = my_container.
if sy-subrc ne 0.
* do nothing.
endif.
* register event
myevent-eventid = html_control->m_id_sapevent.
myevent-appl_event = 'x'.
append myevent to myevent_tab.
call method html_control->set_registered_events
exporting
events = myevent_tab.
create object evt_receiver.
set handler evt_receiver->on_sapevent
for html_control.
perform load_graphics.
perform load_home_page.
endif.
exporting
object_id = 'ZSAP_IMG'
object_url = ‘image.jpeg’
exceptions
others = 1.
exporting
document_id = 'ZTEST_PAGE_6'
importing
assigned_url = doc_url
exceptions
others = 1.
if sy-subrc eq 0.
call method html_control->show_url
exporting
url = doc_url.
endif.
Friday, March 19, 2010
IDOC /AFS/WMMBID02 message type : WMMBXY
I was Debugging the stranded code for more than 2 days and later i Found out that this occurs since the idoc requires few more information. this was mentioned on SAP note 833603.
Symptom
You want to post goods receipt for a stock transport order using an IDoc .
More Terms
WMMBXY, WMMBID01, WMMBID02, MBGMCR, L_IDOC_INPUT_WMMBXY
Cause and Prerequisites
It is not clear how the segments are to be filled, to ensure correct
assignment and updating of the delivery if necessary.
Solution
The following sections only take into account processing with SAP core s
tandard functions and do not include industry solutions.
1. Goods receipt for delivery
a) WMMBXY (WMMBID01, WMMBID02)
The following fields in the segment E1MBXYI must be filled:
EBELN Purchase order number
EBELP Purchase order item
KZBEW Movement indicator = 'B'
POSNR Delivery item (with leading zeros)
VBELN Delivery (with leading zeros)
b) MBGMCR (MBGMCR01, MBGMCR02)
Prerequisite: Note 356665 and basic type MBGMCR02 (not MBGMCR01).
The segment E1BP2017_GM_CODE receives the value GM_CODE = '01'.
In the segment E1BP2017_GM_ITEM_CREATE, the following must be
filled:
PO_NUMBER Purchase order number
PO_ITEM Purchase order item
MVT_IND Movement indicator = 'B'
In the subordinate segment E1BP2017_GM_ITEM_CREATE1, the following
must be filled:
DELIV_NUMB Delivery (with leading zeros)
DELIV_ITEM Delivery item (with leading zeros)
2. Goods receipt for the inbound delivery
a) WMMBXY (WMMBID01, WMMBID02)
In the segment E1MBXYI, no purchase order must be assigned. The
fields EBELN and EBELP remain blank. The movement indicator (KZBEW)
receives the value 'B'.
In the subordinate segment E1MBXYJ, the following are to be filled:
VLIEF_AVIS Inbound delivery
VBELP_AVIS Inbound delivery item
b) MBGMCR
The segment E1BP2017_GM_CODE receives the value GM_CODE = '01'.
In the segment E1BP2017_GM_ITEM_CREATE, no purchase order must be
assigned. The fields PO_NUMBER and PO_ITEM remain blank. The
following must be filled:
MVT_IND Movement indicator = 'B'
DELIV_NUMB_TO_SEARCH Inbound delivery (with leading zeros)
DELIV_ITEM_TO_SEARCH Inbound delivery item (with leading zeros)
IDOCs of the message type WMMBXY are updated using the function
module L_IDOC_INPUT_WMMBXY. In this module, you can change data
using the user exit 'EXIT_SAPLLMDE_002'. Here, use Transaction CMOD
to activate the SAP enhancement MWMIDO08 and implement the required
changes in the exit function module EXIT_SAPLLMDE_002.
hope this post will help someone else who might get stuck like me
Tuesday, March 9, 2010
selection option recommended sign
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name EQ 'S_WERKS-LOW'.
screen-required = 2. "2 is recommended
ENDIF.
MODIFY SCREEN.
ENDLOOP.
Monday, March 8, 2010
selection screen with tabs
SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_ebeln FOR zconf_stage-ebeln,
s_ebelp FOR zconf_stage-ebelp,
s_bsart FOR ekko-bsart,
s_werks FOR ekpo-werks,
s_matnr FOR ekpo-matnr,
s_lifnr FOR ekko-lifnr,
s_ekgrp FOR ekko-ekgrp,
s_budat FOR zconf_stage-budat,
s_kunnr FOR vbpa-kunnr.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF SCREEN 101.
SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN .
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_ebeln1 FOR zconf_stage-ebeln,
s_bsart1 FOR ekko-bsart,
s_werks1 FOR ekpo-werks ,
s_matnr1 FOR ekpo-matnr,
s_lifnr1 FOR ekko-lifnr,
s_ekgrp1 FOR ekko-ekgrp,
s_budat1 FOR zconf_stage-budat,
s_kunnr1 FOR vbpa-kunnr.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF SCREEN 102.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 24 LINES,
TAB (30) button1 USER-COMMAND on,
TAB (30) button2 USER-COMMAND auto,
END OF BLOCK mytab.
INITIALIZATION.
button1 = text-011.
button2 = text-012.
mytab-prog = sy-repid.
mytab-dynnr = 101.
mytab-activetab = 'BUTTON1'.
AT SELECTION-SCREEN .
IF sy-batch = 'X'.
mytab-dynnr = 102.
mytab-activetab = 'BUTTON2'.
sy-ucomm = 'AUTO'.
ENDIF.
CASE sy-dynnr.
WHEN 1000.
CASE sy-ucomm.
WHEN 'ON'.
mytab-dynnr = 101.
mytab-activetab = 'BUTTON1'.
WHEN 'AUTO'.
mytab-dynnr = 102.
mytab-activetab = 'BUTTON2'.
endcase.
WHEN 0101.
mytab-dynnr = 101.
mytab-activetab = 'BUTTON1'.
WHEN 'ONLI'.
PERFORM screen_validation101.
ENDCASE.
WHEN 0102.
mytab-dynnr = 102.
mytab-activetab = 'BUTTON2'.
case sy-ucomm.
WHEN 'ONLI'.
PERFORM screen_validation102.
ENDCASE.
ENDCASE.
START-OF-SELECTION.
CASE mytab-activetab.
WHEN 'BUTTON1'."online mode
WHEN 'BUTTON2'." when automatic
ENDCASE.
now the above code is to a selection screen with tabs that you code using a report program.( this code cannot be used in module pool program )
When a customer request to a selection screen with tabs there can be 2 reasons.
1) To group a selection on one out put ( I mean the final out-put is one but selection screen can be with tabs to make things clear for e.g on SD related report the tabs can be Material selection , SO selection like wise )
2) The user requires different kind of out comes with different tabs... for e.g tab no1 to work during online operations and tab no 2 to work on background operations.
The above requirement 1 which will be totally fine with the code given on top. But the requirement 2 will be a issue when it comes to the above code. As most of the developers know on a selection screen we will always have mandatory fields. when switching between tabs the selection screen first calls the validation and then it calls the normal screen code ( as you know the validation is automatic if me make a selection option mandatory and we have no say on it ).
So in case if the user wants the functionality of the tab 2 he first has to fill all the mandatory fields on tab 1 so that the error wont occur. This was a error I had to face during my development for this there are 2 way outs
1) do the validation by your self ( draw back : you wont get the mandatory sign on the selection screen )
2) write a selection screen with tabs ( draw back : the user wont be able to save variants or this part has to be coded which will be a messy job )
for the 2nd option on above to make sure the tab switching with happen without first validating you have to do the codding as follows
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE set_tabs.
call SUBSCREEN SUB INCLUDING sy-repid gv_dynnr.
*
PROCESS AFTER INPUT.
MODULE exit_comm.
MODULE switch_tab.
CALL SUBSCREEN SUB.
MODULE screen_comm.
MODULE USER_COMMAND_0100.
before call sub screen you have to call a module switch tabs.
on my case my customer wanted the variants to be there. Therefore they agreed to the validation by code where the mandatory sign is not displayed.
Tuesday, March 2, 2010
five months of busy work
but there were few limitations which I came a cross when I developed tab striped selection screen which I am hoping to blog sometime in the future.
till then enjoy reading my old post's on SAP but still there is nothing much since from the time I joined my work place I hardly had any free time.
Friday, September 11, 2009
Copy to Clipborad SAP
Bellow code is how to copy data to clipboard. This feature helps you when there is a BDC recording and you want to add selection extended options
DATA: v_rc TYPE I,
it_data TYPE STANDARD TABLE OF CHAR128,
wa_data TYPE char128.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_EXPORT
IMPORTING DATA = it_data
CHANGING RC = v_rc .
Monday, August 31, 2009
How to add a button on selection screen
one small thing I came across on a customer development was to add a button on the selection screen. I have not done such a requirement before for any customer so i didn't any idea on how to do it.
After doing some searching this is what I found out was :).
For a selection screen you can put up to 5 buttons this is a default feature which is available to use if you want.
For that these are the steps you have to do
I have added the button in two ways one is just the button with the text next one button with a icon.
The data declarations for these are.
TABLES: sscrfields.
DATA: functxt TYPE smp_dyntxt.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
TITLE TEXT-001.
SELECT-OPTIONS: p_ktopl FOR t030-ktopl.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
functxt-icon_id = ICON_HISTORY.
functxt-quickinfo = 'log'(001).
sscrfields-functxt_01 = functxt.
MOVE 'Maintain Item Cat.' TO sscrfields-functxt_02.
Thursday, July 16, 2009
how to add tooltip to icon
its very easy to add tooltip to icon's
1) have a icon field in output table ( this can be a char field with 25 characters)
2) in case if you cant to add the lock icon for that icon field put
in this @06@ is the icon when you give the tooltip with '\QXXXtooltipXXX'
insert this part beore last @.
Note: if you want to find the icons check icon table :)
3) field catalog make the icon field 'X'.
there is a SAP example on program: BCALV_DEMO_TOOLTIP
Tuesday, June 23, 2009
How to Debug any screen on SAP
[FUNCTION]
Command=/H
Title=Debugger
Type=SystemCommand
when ever you want to debug you dont have to use /h but just drag and drop this on the SAP screen this enables you to debug on popup screens
Hope this will be useful
nafran
Wednesday, June 10, 2009
how to get the first day and last day SAP
*get first and last date of month and year
CONCATENATE s_bdatj-low s_mnr-low '01' INTO gv_date1.
gv_month = s_mnr-low .
gv_month = gv_month + 01.
CONCATENATE s_bdatj-low gv_month '01' INTO gv_date2.
gv_date2 = gv_date2 - 1.
Monday, June 8, 2009
only way of parallel or Multi Threading on SAP
Hmm.... there is only one way that I can think about in SAP and we can get all most all features on Parallel processing from this way.
CALL FUNCTION 'Fetch_Data' STARTING NEW TASK 'Fetch' performing RETURN_FROM_WAIT ON END OF TASKEXPORTING input = input TABLES output = output EXCEPTIONS COMMUNICATION_FAILURE = 1 SYSTEM_FAILURE = 2. Important : you cant use any import parameters on the function no this method the only option is to using theRETURN_FROM_WAIT which is a perform. For Eg when you want to fetch data parallel do it using 2 functions and using the perform you can have a flag to make sure that fetching is completed.This is just a over view I got this document from Daniel Perecky Multi Threading this has lots of information no how to program this way. I would love to see some comments about this :)
Friday, May 22, 2009
create custom menu exits
where a generic menu bar is required which can add items according to the customer.
the first thing to do in such requirement is to add a fcode in menu painter starting with +XXX ( replace X).
once this is done handle the fcode using a function
CALL CUSTOMER-FUNCTION '010'.
with in this function you can do what ever you what to do for when that item is clicked.
then on a standard SAP enhancement(smod) add your program name and the fcode and add your function exit on it.
create a project on cmod and add the enhancement you will find the exit and the menu exit.
if this is not clear pls post a comment ( coz i just wrote it in a way how i will understand)
Thursday, May 7, 2009
best way to code nested loops SAP
REPORT ZPARALLEL_CURSOR.
TABLES:
likp,
lips.
DATA:
t_likp TYPE TABLE OF likp,
t_lips TYPE TABLE OF lips,
t_lips1 TYPE SORTED TABLE OF lips
WITH NON-UNIQUE KEY vbeln.
DATA:
w_runtime1 TYPE I,
w_runtime2 TYPE I,
w_counter TYPE I,
w_index LIKE sy-INDEX.
DATA:
likp_l TYPE I,
lips_l TYPE I.
PARAMETERS: rows TYPE i OBLIGATORY.
START-OF-SELECTION.
SELECT *
FROM likp
INTO TABLE t_likp up to rows ROWS.
DESCRIBE TABLE t_likp LINES likp_l.
WRITE:/ 'records in likp: ' .
WRITE likp_l.
SELECT *
INTO TABLE t_lips
FROM lips
FOR ALL ENTRIES IN t_likp
WHERE vbeln = t_likp-vbeln.
DESCRIBE TABLE t_lips LINES lips_l.
WRITE:/ 'records in lips: ' .
WRITE lips_l.
**********************************************************************
**********************************************************************
**********************************************************************
GET RUN TIME FIELD w_runtime1.
LOOP AT t_likp INTO likp.
LOOP AT t_lips INTO lips WHERE vbeln EQ likp-vbeln.
ENDLOOP.
ENDLOOP.
GET RUN TIME FIELD w_runtime2.
w_runtime2 = w_runtime2 - w_runtime1.
WRITE:/.
WRITE:/'Time taken on normal where condition:'.
WRITE: w_runtime2.
**********************************************************************
**********************************************************************
**********************************************************************
GET RUN TIME FIELD w_runtime1.
SORT t_likp BY vbeln.
SORT t_lips BY vbeln.
LOOP AT t_likp INTO likp.
LOOP AT t_lips INTO lips FROM w_index.
IF likp-vbeln NE lips-vbeln.
w_index = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
GET RUN TIME FIELD w_runtime2.
w_runtime2 = w_runtime2 - w_runtime1.
WRITE:/.
WRITE:/.
WRITE:/'Time taken with parallel cursor:' , w_runtime2.
**********************************************************************
**********************************************************************
**********************************************************************
GET RUN TIME FIELD w_runtime1.
SORT t_lips BY vbeln.
t_lips1[] = t_lips[].
LOOP AT t_likp INTO likp.
LOOP AT t_lips1 INTO lips WHERE vbeln EQ likp-vbeln.
ENDLOOP.
ENDLOOP.
GET RUN TIME FIELD w_runtime2.
w_runtime2 = w_runtime2 - w_runtime1.
WRITE:/.
WRITE:/.
WRITE:/'Time taken for a sorted table with where condition:' , w_runtime2.
