SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Process on value request – F4



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Search Help, Match Code
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Mon Sep 10, 2007 7:05 pm    Post subject: Process on value request – F4 Reply with quote

Code:
PROCESS ON VALUE-REQUEST.
  FIELD zpcr-source MODULE source_help.

MODULE source_help INPUT.

DATA: BEGIN OF ivalue_source OCCURS 0,
       source LIKE zsource-source,
       source_desc LIKE zsource-source_desc,
      END OF ivalue_source.
DATA: BEGIN OF ivalue_category OCCURS 0,
Data: w_progname LIKE sy-repid,
      w_scr_num LIKE sy-dynnr .
DATA: return_values LIKE ddshretval OCCURS 0 WITH HEADER LINE.
DATA: itab_dynpfields LIKE dynpread OCCURS 0 with header line,
      t_dynpfields LIKE dynpread.
DATA: t_dyname LIKE d020s-prog,
      t_dynumb LIKE d020s-dnum.

  SELECT source source_desc FROM zsource INTO TABLE ivalue_source.
  IF sy-subrc = 0.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
         EXPORTING
              retfield        = 'SOURCE'
              dynpprog        = w_progname
              dynpnr          = w_scr_num
              dynprofield     = 'ZPCR-SOURCE'
              value_org       = 'S'
         TABLES
              value_tab       = ivalue_source
              return_tab      = return_values
         EXCEPTIONS
              parameter_error = 1
              no_values_found = 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.
    ELSE .
      zpcr-source = return_values-fieldval.
      SELECT SINGLE source_desc INTO zsource-source_desc
        FROM zsource
        WHERE source = zpcr-source.
    ENDIF.
  ELSE.
    MESSAGE i999(b1) WITH 'No values in ZSOURCE table'.
  ENDIF.

  REFRESH itab_dynpfields. CLEAR: itab_dynpfields.
  t_dynpfields-fieldname = 'ZSOURCE-SOURCE_DESC'.
  APPEND t_dynpfields TO itab_dynpfields.

  t_dynumb = sy-dynnr.
  t_dyname = sy-repid.

* This function module must have the values added to
* the internal table that you need t oread.
  CALL FUNCTION 'DYNP_VALUES_READ'
       EXPORTING
            dyname               = t_dyname
            dynumb               = t_dynumb
       TABLES
            dynpfields           = itab_dynpfields
       EXCEPTIONS
            invalid_abapworkarea = 1
            invalid_dynprofield  = 2
            invalid_dynproname   = 3
            invalid_dynpronummer = 4
            invalid_request      = 5
            no_fielddescription  = 6
            invalid_parameter    = 7
            undefind_error       = 8
            double_conversion    = 9
            stepl_not_found      = 10
            OTHERS               = 11.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  LOOP AT itab_dynpfields.
    CASE itab_dynpfields-fieldname.
      WHEN 'ZSOURCE-SOURCE_DESC'.
        itab_dynpfields-fieldvalue = zsource-source_desc.
        MODIFY itab_dynpfields.
    ENDCASE.
  ENDLOOP.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
       EXPORTING
            dyname               = t_dyname
            dynumb               = t_dynumb
       TABLES
            dynpfields           = itab_dynpfields
       EXCEPTIONS
            invalid_abapworkarea = 1
            invalid_dynprofield  = 2
            invalid_dynproname   = 3
            invalid_dynpronummer = 4
            invalid_request      = 5
            no_fielddescription  = 6
            undefind_error       = 7
            OTHERS               = 8.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDMODULE.                 " source_help  INPUT


Example 2
Code:

*&---------------------------------------------------------------------*
*& Report ZF4HELP *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZF4HELP .
DATA : BEGIN OF ITAB OCCURS 0,
LINE(80) TYPE C,
END OF ITAB.

PARAMETERS : P_HELP(30) TYPE C.
DATA INDEX TYPE I.
DATA SELECTION LIKE LINE OF ITAB.
START-OF-SELECTION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_HELP.
REFRESH ITAB.
ITAB-LINE = 'First line'. APPEND ITAB.
ITAB-LINE = 'Second line'. APPEND ITAB.
ITAB-LINE = 'Third line'. APPEND ITAB.
ITAB-LINE = 'Fourth line'. APPEND ITAB.
ITAB-LINE = 'Fifth line'. APPEND ITAB.
DATA LINE TYPE I.
DESCRIBE TABLE ITAB LINES LINE.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
ENDPOS_COL = 20
ENDPOS_ROW = LINE
STARTPOS_COL = 1
STARTPOS_ROW = 1
TITLETEXT = 'Select Value'
IMPORTING
CHOISE = INDEX
TABLES
VALUETAB = ITAB
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2.

READ TABLE ITAB INDEX INDEX.
IF SY-SUBRC EQ 0.
SELECTION = ITAB-LINE.
P_HELP = SELECTION.
ENDIF.

END-OF-SELECTION.
WRITE : / 'You selected ' ,SELECTION.


Example 3
Code:

*----------------------------------------------------------------------*
*   INCLUDE Y_F4_VALUES                                                *
*----------------------------------------------------------------------*
*
*
          Define Insert_Separators.
                 Move '|' to t_f4_help-col1.
                 Move '|' to t_f4_help-col2.
                 Move '|' to t_f4_help-col3.
                 Move '|' to t_f4_help-col4.
          End-of-Definition.

* Macro F4_Value_Request
*
* &1    Parameter for F4 Value Request from ABAP program
* &2    Table to select possible values from for &1
* &3    Field for Parameter from relevant table
* &4    Field for description of &3
* &5    Translation field key
* &6    Title for the f4 popup
* &7,8 and 9 - Text headers for columns
*
Define F4_Value_Request.
*
       At Selection-Screen on value-request for &1.
*
*
*         At the moment,  select all company codes,
*
          Data: Begin of t_f4_help occurs 0,
                      Col1    type c,
                      &3      like &2-&3,
                      Col2    type c,
                      &4      like &2-&4,
                      Col3    type c,
                      IAS(15) type c,
                      Col4    type c,
                End of t_f4_help,
*
                w_sap_data         type zoutwards,
                w_legacy_data      type zinwards,
                w_choise           like sy-tabix,
                w_lines            like sy-tabix,
                w_endpos_col       type i.
*
          Move sy-uline to t_f4_help.
          Append t_f4_help.
          Move &7 to t_f4_help-&3.
          Move &8 to t_f4_help-&4.
          Move &9 to t_f4_help-IAS.
          Insert_Separators.
          Append t_f4_help.
          Move sy-uline to t_f4_help.
          Append t_f4_help.
          Select &3 &4
            into (t_f4_help-&3,
                  t_f4_help-&4)
            from &2
           where spras = sy-langu.
                 Append t_f4_help.
          EndSelect.
          Loop at t_f4_help.
               If sy-tabix > 3.
                  Insert_Separators.
                  Modify t_f4_help.
               EndIf.
          EndLoop.
          Move sy-uline to t_f4_help.
          Append t_f4_help.
*
          Describe table t_f4_help lines w_lines.
          If w_lines > 4.
*
*            Display....
*
*            Calculate the width of the table.
*
             Read Table t_f4_help index 1.
             Compute w_endpos_col = 10 + strlen( t_f4_help ).
             Call Function 'POPUP_WITH_TABLE_DISPLAY'
               Exporting
                  Endpos_Col         = w_endpos_col
                  Endpos_Row         = 25
                  Startpos_Col       = 10
                  Startpos_Row       = 10
                  Titletext          = &6
               Importing
                  Choise             = w_choise
               Tables
                  Valuetab           = t_f4_help
               Exceptions
                  Break_Off          = 1
                  Others             = 2.
             If sy-subrc  = 0.
*
*               Make sure that they haven't selected a title or an
*               underscore.
*
                If w_choise > 3
                   and w_choise < w_lines.
                       Read Table t_f4_help index w_choise.
                       Move t_f4_help-&3 to &1.
                EndIf.
             EndIf.
          Else.
             Message W000 with 'No Values For List'.
          EndIf.
End-of-definition.


Use it like so:

Code:

REPORT Y_Agents
       Message-id 38
       Line-Size  110
       Line-Count 0
       No Standard Page Heading.
*
Include Y_Agents_Top.
Include y_f4_Values.
*
* Selection Criteria
*
Begin_Of_Block Parms Text-001.
      Selection-Screen Begin Of Line.
                Selection-Screen Comment 1(31) Text-012.
                Parameters: p_bukrs like bsis-bukrs obligatory,
                            p_butxt like t001-butxt.
      Selection-Screen End of line.
      Select-Options s_kunnr for bseg-kunnr.
      Selection-Screen Skip 1.
      Begin_Of_Block Doc_Select Text-005.
            Selection-Screen skip 1.
            Begin_Of_Block Docs Text-006.
                  Select-Options: s_belnr for bsis-belnr.
            End_of_Block Docs.
            Selection-Screen skip 1.
            Begin_Of_Block Dates Text-002.
                  Select-Options: s_bldat for bsis-bldat.
                  Blankline.
                  Select-Options: s_monat for bsis-monat.
                  Parameters:     p_gjahr like bsis-gjahr.
            End_Of_Block Dates.
     End_of_Block Doc_Select.
     Begin_Of_Block Rem_Cmnt Text-007.
           Parameters: p_freq  type ZAgents_frequency obligatory.
     End_Of_Block Rem_Cmnt.
End_Of_Block Parms.
*
* Pick Lists
*
F4_Value_Request p_bukrs
                 t001 bukrs butxt
                 BUKRS Text-055 Text-056 Text-057 Text-058.
*
F4_Value_Request_belnr s_belnr-low
                       bseg belnr sgtxt
                       BELNR_D Text-059 Text-060 Text-061 Text-058.
F4_Value_Request_belnr s_belnr-high
                       bseg belnr sgtxt
                       BELNR_D Text-059 Text-060 Text-061 Text-058.
*
* Parameter validation.
*
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Search Help, Match Code All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.