Wednesday, February 22, 2012

Wildcard Search on any particular field inside a program/FM

 IF pfrom CA '*' OR pto CA '*'.
    wildcard = '1'.
    prange-sign   = 'I'.
    prange-option = 'CP'.
    prange-low    = pfrom.
    APPEND prange.
    EXIT.
  ENDIF.


  IF      NOT pto   IS INITIAL
      AND NOT pfrom IS INITIAL.
    prange-sign   = 'I'.
    prange-option = 'BT'.
    prange-low    = pfrom.
    prange-high   = pto.
    APPEND prange.
  ELSEIF NOT pfrom IS INITIAL.
    prange-sign   = 'I'.
    prange-option = 'EQ'.
    prange-low    = pfrom.
    APPEND prange.
  ELSEIF NOT pto IS INITIAL.
    prange-sign   = 'I'.
    prange-option = 'BT'.
    CLEAR pfrom.
    prange-low    = pfrom.
    prange-high   = pto.
    APPEND prange.
  ENDIF.

Wednesday, October 12, 2011

Search Helps with Search Help Exit

Create a search help either with view or DB table depending on requirement.
then assith the Table/View in search help(my requirement was satisfied by Elementary, same approach )

Delcare Changing & Tables in the Search help exit

Then customize the following code according to the requirements


FUNCTION zirm_prdclass_brand.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     REFERENCE(SHLP) TYPE  SHLP_DESCR
*"     REFERENCE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
*"----------------------------------------------------------------------

  TYPESBEGIN OF ty_mara,
          matnr TYPE matnr,
           vkorg TYPE vkorg,
           vtweg  TYPE vtweg,
          prodh TYPE prodh_d,
         END OF ty_mara,

         BEGIN OF ty_final,
           matnr TYPE matnr,
           vkorg TYPE vkorg,
           vtweg  TYPE vtweg,
           zzprodh4  TYPE zzprodh4,
           zzprodh5  TYPE zzprodh5,
           zzprodh6  TYPE zzprodh6,
           END OF ty_final.

  DATA: lt_mara TYPE STANDARD TABLE OF ty_mara,
        lt_final TYPE STANDARD TABLE OF ty_final,
        ls_mara TYPE ty_mara,
        ls_final TYPE ty_final.
  DATA: it_mara TYPE STANDARD TABLE OF mvke,
        w_mara TYPE mvke,
        w_selopt LIKE LINE OF shlp-selopt,
        w_fielddrop LIKE LINE OF shlp-fieldprop.

  DATA: l_vkorg(1).

  IF callcontrol-step = 'SELECT'.
    READ TABLE shlp_tab INDEX 1.
    CLEAR: l_vkorg.
    LOOP AT shlp-selopt INTO w_selopt.
      IF w_selopt-shlpfield = 'MATNR'.
        w_mara-matnr = w_selopt-low.
      ELSEIF w_selopt-shlpfield = 'VKORG'.
        w_mara-vkorg = w_selopt-low.
        l_vkorg = 'X'.
      ELSEIF w_selopt-shlpfield = 'VTWEG'.
        w_mara-vtweg = w_selopt-low.
      ENDIF.
    ENDLOOP.
    IF w_mara IS NOT INITIAL.
      APPEND w_mara  TO it_mara .
    ENDIF.


    LOOP AT shlp-fieldprop INTO w_fielddrop
    WHERE fieldname CS 'ZZPROD'.
      w_fielddrop-shlpoutput = 'X'.
      MODIFY shlp-fieldprop FROM w_fielddrop.
    ENDLOOP.
    CLEAR: w_fielddrop.
    IF NOT it_mara IS INITIAL AND l_vkorg = 'X'.
      SELECT matnr vkorg vtweg prodh FROM mvke
        INTO TABLE lt_mara
        FOR ALL ENTRIES IN it_mara
        WHERE matnr = it_mara-matnr
          AND vkorg = it_mara-vkorg.
    ELSEIF NOT it_mara IS INITIAL .
      SELECT matnr vkorg vtweg prodh FROM mvke
        INTO TABLE lt_mara
        FOR ALL ENTRIES IN it_mara
        WHERE matnr = it_mara-matnr.
    ELSE.
      SELECT matnr vkorg vtweg prodh FROM mvke
        INTO TABLE lt_mara.
    ENDIF.
    IF NOT lt_mara IS INITIAL.
      LOOP AT lt_mara INTO ls_mara.
        ls_final-matnr = ls_mara-matnr.
        ls_final-vkorg = ls_mara-vkorg.
        ls_final-vtweg = ls_mara-vtweg.
        IF shlp_tab-shlpname = 'ZIRM_BRAND'.
          ls_final-zzprodh4 = ls_mara-prodh+6(3).
        ELSEIF shlp_tab-shlpname = 'ZIRM_PRD_CLASS'.
          ls_final-zzprodh5 = ls_mara-prodh+9(3).
        ELSE.
          ls_final-zzprodh6 = ls_mara-prodh+12(3).
        ENDIF.
        APPEND ls_final TO lt_final.
      ENDLOOP.

    ENDIF.


    CALL FUNCTION 'F4UT_RESULTS_MAP'
      TABLES
        shlp_tab          = shlp_tab
        record_tab        = record_tab
        source_tab        = lt_final
      CHANGING
        shlp              = shlp
        callcontrol       = callcontrol
      EXCEPTIONS
        illegal_structure = 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.

    callcontrol-step = 'DISP'.

  ENDIF.

  REFRESH: it_mara,
           lt_mara,
           lt_final.
ENDFUNCTION.

Monday, April 18, 2011

SAP translations and transports for them

To assign a transport request for the translations that were done, execute the program RS_LXE_RECORD_TORDER.





Reference from :
http://www.saptechnical.com/Tutorials/Smartforms/TransportRequest/Assign.htm

Tuesday, March 22, 2011

How to identify a BADI for a TCODE

Go to se24 and display class CL_EXITHANDLER - view the code behind method GET_INSTANCE. place a break-point there somewhere in the beginning. 

Now, go to your tcode in another session and execute it. Your breakpoint will be hit every time a BADI is called.

Friday, November 12, 2010

Important Tables

TJ30 -- Table that contains User status table with Profile ID, Status Id and Status Description

Monday, August 23, 2010

Interactive ALV report

Sample code for Interactive ALV reports( Fetch records from VBAK, on clicking any output record, navigate to Sales Doc Tcode)


*&---------------------------------------------------------------------*
*&      Form  ALV_DISPLAY
*&---------------------------------------------------------------------*
FORM alv_display .

  PERFORM build_fieldcatalog.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_bypassing_buffer      = 'X'
      i_callback_program       = sy-repid
      i_callback_user_command = 'USER_COMMAND'
*      i_grid_title            = 'Interactive ALV'
      it_fieldcat             = i_fieldcatalog[]
      is_layout               = w_layout
      it_sort                 = i_sort
      i_default               = 'X'
      i_save                  = 'A'
      is_variant              = w_variant
      it_events               = i_grid_event
    TABLES
      t_outtab                = i_vbak[]
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
ENDFORM.                    " ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.

*  CLEAR fcat1.
  DATA: t_doc TYPE vbeln.
  CLEAR: w_vbak.
  CASE u_com.
    WHEN '&IC1'.
      READ TABLE i_vbak INTO w_vbak INDEX sel_field-tabindex.
      IF sy-subrc = 0.
        t_doc = w_vbak-vbeln.
        SET PARAMETER ID 'AUN' FIELD t_doc.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDIF.
  ENDCASE.
ENDFORM"user_command

Thursday, August 12, 2010

FM for Downloading data to apps -windows folder

soon after close dataset, embed this code.. pass your file path..thats it

*************
lv_additional_parameters = lv_filename.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = 'ZCHMODR'
additional_parameters = lv_additional_parameters. "'/sap_report/ED2/report/finance/productcosting/TEst_UNIX.txt'
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

***************




TRINT_SPLIT_FILE_AND_PATH


SUBST_GET_FILE_LIST file path validation